Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Do child trigger runs parent trigger also?

Tags:

c#

unity3d

I have a gameObject whose hierarchy contains

  1. parent contains box collider, kinematic rigidbody and script that contains OnTriggerEnter event.
  2. Parent's first child contains box collider
  3. Parent's first child of a child contains box collider and script contains OnTriggerEnter
  4. Parent's first child of seconds child contains box collider and script contains OnTriggerEnter My simple question is do child trigger will run parent trigger also I have did it. it seems true and surprising!
like image 753
Muhammad Faizan Khan Avatar asked Mar 11 '23 21:03

Muhammad Faizan Khan


1 Answers

They do if the child does not have a (kinematic) rigidbody. In this case the collider of the parent basically is the sum of all colliders of itself and it's childs (compound collider).

If you want them to behave individually, they need their own kinematic rigidbodys. Make sure they ignore each other in the OnTrigger though (e.g. via tag).

like image 120
Gunnar B. Avatar answered Mar 24 '23 08:03

Gunnar B.