How to ignore OnTriggerEnter call of child ?

Hello, I’m facing a little issue :

I have a GameObject “Player” with a trigger collider and a script “Character”.
In that script, I implement OnTriggerEnter in which I just print(“Entered”).

So that if my Player touches anything, I should see “Entered” in the console.

So far so good.

Now my Player as a child gameobject with a trigger collider that’s bigger than its parent, but no script.
When that trigger collider touches anything, it also prints “Entered” in the console.

How can I make it so that I only print “Entered” if it’s the parent that hits anything (and do nothing if the child hits anything) ?

Thanks !

That’s kinda just how the physics system works. Any colliders that are on the same game object or child game objects of a rigidbody are all kind of one big collider for said rigidbody.

Any collisions or trigger events on child components get proliferated upwards until they reach the game object with the rigidbody. I don’t believe there’s a way to override this.

If you don’t want a parent to recieve events from a child, then it should be a sibling and not a child.

How to control collisions and triggers before they happen:

  • You can put colliders on objects that are on different layers, and adjust the Physics settings to naturally skip interactions between those layers
  • You can call Physics.IgnoreCollisions(a, b) with two colliders you never want to interact; you can loop through with GetComponentsInChildren() to find a bunch of things

How to control collisions and triggers after they happen:

  • Check the object for clues as to whether you want to process it, before you process it. GameObject tags, GetComponent<>() calls, name, layer, etc.

Yeah I ended up using a different layer for it, thanks !