- Home /
OnTriggerStay2D Breaks When Adding AnimationController
In my scene I have an object which has a RigidBody2D and BoxCollider2D component with "Trigger" set to false. Then I have an object with a BoxCollider2D with "Trigger" set to true and a Script.
The script contains: public void OnTriggerStay2D(Collider2D collider) { ... }
If I run the game when the rigidbody enters the trigger area then OnTriggerStay2D is fired within the script. This works as expected.
HOWEVER if I add an Animator AND assign it an AnimationController then I find that OnTriggerStay2D is no longer firing within the script.
Why is this? How can I fix it?
Answer by StickFigs · Apr 09, 2014 at 08:20 PM
Fixed it by creating an empty GameObject, moving the BoxCollider2D and Script components from the original GameObject to the new empty one, and making the original GameObject with Sprite and Animator components a child of the new GameObject with just Collider and Script components. Now sprite animates correctly and collider no longer breaks.