- Home /
OnTriggerEnter2D Doesn't fire after switching to IsTrigger on
Hi all,
So I have a simple rigidbody 2D with a box collider, sitting on top of another rigidbody 2D with a box collider.
I then switch the box underneath to IsTrigger, and the top box falls through as expected.
The only problem is that OnTriggerEnter2D or OnTriggerStay2D doesn't fire. It only fires once the object is moved out of the bounds of the first object, then moved back in.
Does anyone know why this is, and a possible solution?
Thanks!
Answer by thehen2 · May 21, 2014 at 02:03 PM
So my super hacky solution was to add another collider component that isTrigger and make it slightly smaller than the actual collider. This then triggers as expected.
Answer by Jeff-Kesselman · May 21, 2014 at 12:30 AM
Likely your moving box is already penetrating the collider of the obstacle box when it starts.
Move it so its a bit above and see if the same thing happens.
Thanks for the reply, this is what I thought, and is the behaviour. I have various shapes and this occurs when pushing from the side, sitting on top etc, so moving the collider above won't be a universal solution. Any ideas how I could resolve this?