Hi, I'm new here. What are the steps needed to create a custom collision category and use it with the interaction filters? I think I am missing something.
I have an abstract class MyCrate which extends Crate.
In the constructor of MyCrate, I add the category with this:
I want my hero to sometimes collide with the custom crates, and other times pass through them. I have a class "Man" which extends Hero.
In handleBeginContact() in the Man class, I check to see if the collider is MyCrate.
If it is, I set the Man's interaction filter to either collide or ignore.
override public function handleBeginContact(callback:InteractionCallback):void
var collider:NapePhysicsObject = NapeUtils.CollisionGetOther(this, callback);
var collFilter:InteractionFilter = new InteractionFilter();
collFilter.collisionGroup = PhysicsCollisionCategories.Get("GoodGuys");
if (collider is MyCrate)
collFilter.collisionMask = PhysicsCollisionCategories.GetAll();
When I run it, the Man never ignores MyCrate. Instead, he collides with MyCrate in BOTH conditions (I've used trace statements to verify that the "shouldCollide" boolean is working properly).
If I change ...GetAllExcept("MyCrate") to GetAllExcept("BadGuys"), I can see the proper behavior in the Man (he sometimes gets hurt by enemies, sometimes passes through them). So I know it's working in theory. But somehow my custom category "MyCrate" is not setup or working right.
Thanks for any help!