Unity – Compound Colliders Firing Multiple Trigger Handlers

      Comments Off on Unity – Compound Colliders Firing Multiple Trigger Handlers

Recently I had a problem with the AI system that I’m building, in which I had calls to OnTrigger events that shouldn’t have been reached. My Colliders were set up as such:

The outer collider is being used as a distance check to see if the player is within the range of being seen by the enemy. The inner collider is a hit detection collider for player bullets. These perceptors work with the AI behavior manager to move the AI between behavior states. Each perceptor has a script that handles the OnTriggerEnter events and passes that data up, so it came as a surprise when the the player would trigger the outer collider I was seeing both its trigger event and the inner colliders event being handled at the same time.

What I came to find out, was that you need a kinematic rigid body alongside each child collider, otherwise the event will bubble up to the nearest affected rigidbody. Adding a rigid body to each game object, and making them kinematic solved the problem for me.

If you want to learn more please check out this answer thread: