- Home /
OnTriggerEnter not being called with multiple colliders
I have a parent GameObject with a script and a child named Colliders which has several GOs with colliders in it:
ParentGameObject
(MyScript component)
-Colliders
--Collider1
(Collider component)
--Collider2
(Collider component)
My test is the following: Set both colliders to non trigger: OnCollisionEnter gets called in the script. Set both colliders to trigger: OnTriggerEnter DOES NOT gets called in the script.
Any ideas why could this be happening ?
Answer by Agustin Petrini · May 20, 2011 at 12:33 PM
Ok, I got it. Short answer is, because Unity works like that. Long answer: OnCollision* works different than OnTrigger*. OnCollision* is being executed by the engine when any collider of any child collides with anything, because the parameter is aCollision which holds both colliding colliders in every contact point. This way you can actually know which collider(s) of your childs has been touched. This is different in OnTrigger*, since the parameter is aCollider (that is the OTHER collider), the only place where it is executed its on the collider´s container GO, because otherwise you wouldn´t have a way to know which collider from your child has been touched.
Hope this clears things up for somebody.
Agustin
Your answer
Follow this Question
Related Questions
Trouble with triggers and colliders 1 Answer
Parenting On Trigger not Working? 3 Answers
OnTriggerEnter - check if collider is child 1 Answer
Make a simple tree 1 Answer