- Home /
Why OnTriggerEnter2D is triggered on an Object which doesn't include trigger collider?
Hello everyone!
I have following problem.
I am instantiating many clones from a prefab that has CircleCollider2D and has a trigger set to true. After I set one object to move from mouse click, I set that object's trigger collider to false via script:
hit.collider.isTrigger = false;
That happens in a GameManager script. After that object collides with another gameobject's trigger collider, the OnTriggerEnter2D gets fired in both objects: the one which is colliding (=moving) and in the one that is collided with (stationary).
I have debugged the code, and the collider's trigger collider is set to false, but the OnTriggerEnter2D is still triggered in that object as well.
Isn't OnTriggerEnter2D only fire in the object that has trigger collider, and not in the one that doesn't have trigger collider?
I am confused, please help me! Thank u! - Jukka
Answer by hexagonius · Jan 16, 2016 at 04:33 PM
Check out the collision matrices on this page, they also apply for 2D colliders: CollidersOverview
short answer: as long as both participants HAVE colliders, and at least one has isTrigger enabled, both receive that event. It's always both participants for any notification. think of it as "a trigger has entered another trigger/collider, so notify both"
@hexagonius Thank you! Bff, it seemed to simple to be an actual problem. So yet again, a user mistake by not reading the documentation properly.
Thank you again!
Your answer
Follow this Question
Related Questions
Why is my Collider Broken? 0 Answers
Does OnTriggerStay don't detect a collision with a non-trigger collider? 1 Answer
Problems with the Trigger Collider (randomly fictional) 1 Answer
Having problems with playing a sound (C#) 2 Answers
Two colliders on GameObject with only one acting as trigger 2 Answers