Set ContactFilter2d to not use child object's triggers.

In our player’s GameObject, we have a collision box to track the player’s collision, as well as a trigger in a child object that activates when using an attack. To get the movement we wanted, we followed Unity’s 2d platformer physics tutorial which can be found here: Unity Connect

Everything works fine until we enable the child’s trigger. After some degugging, I believe that the ContactFilter2D is using the child object’s trigger as a collider as well. Is there any way to get around this, or will I have to place the triggers in a object that is not a child of the player?

This is definitely a Unity bug with both the ContactFilter2d and RigidBody2d.Cast(). The main issue seems to be that RigidBody2D.Cast() is including the child triggers as part of the object’s overall collider shape, and there is no override option in the function itself to tell it not to do that.

We managed a two step work around, but it isn’t perfect and we won’t be relying on Rigidbody2d.Cast() for anything else until it’s fixed.

The first step is to manually set the LayerMask for the filter to exclude any layers you’re using for triggers.

The second step is to have the actual trigger collider and any OnEnter/Stay/Exit scripts stored in an object outside the rigibody’s hierarchy, then use a placeholder child in the hierarchy. Set up a simple script on a child of the rigidbody to pass its transform values (and any other values like enable, offset, size, etc…) to the external object. If you’re using scale flipping, be mindful to offset the position by the reference object’s scaled local position.

Is this fixed or still happening @OmegaJeff ? we are on the 2017.4.0f1 and still happening, even with the manual setup of the layermask

Still same bug with Unity 2021.3.16f