How to prevent a child object from calling OnTriggerEnter in a parent

  • A parent gameObject has a script with OnTriggerEnter that is called when the gameObject hits a gameObject with tag "exit".
  • The parent also has a child with tag "visibilityCheck" and whenever that child hits the “exit” collider, the parent’s OnTriggerEnter gets called.

How do I get OnTriggerEnter to ignore the collision between the child and the "exit"?

The solution was to add a condition:

if (!col.gameObject.CompareTag("visibilityChecker") == false)