How can I get Compound Colliders to work properly?

I currently have a Sphere object in the library, that I instantiate at the start of the game:
alt text

As you can see from the inspector of the Drone parent object, I have a rigidbody on this object. It does not have a collider. The DroneTrigger object only has a collider on it. I’ve read that with this setup, the child object’s collider will take over for the parent if one of the parent scripts calls OnTriggerEnter. I have yet to make this work as intended.

I am trying to hit the DroneTrigger with a bullet object that I’m firing. When I was just using a collider on the Drone object, it worked fine.

I want this to eventually allow me to use a second child collider for a different collision.

EDIT: I’d like to add that when the player object enters the DroneTrigger trigger, it passes the Player collider fine. It just does not seem to like the one from the Bullet. Before you tell me, I’ve tried using FixedUpdate on the bullet.

Triggers don’t “understand” compound colliders the way other colliders do (NOTE: Unity v4.01f2.) A fix is to add a “find my parent” to them.

As you note, OnCollisionEnter is fine with a rigidbody parent with no collider, but with any number of child non-RB colliders. Hits on any kid count as hits on the parent, and you can check which exact kid it was. In code, collision.transform is the main RB object, and collision.collider is the particular kid.

But, with triggers, they only tell you the particular collider that entered/left/stayed. Even worse, If kid1 enters, and then kid2, they count both – triggers are too “dumb” to know parentRB + kid1 + kid2 form one compound collider object.

A workaround is to find the parent yourself:

void OnTriggerEnter(Collider cc) {
  Transform T = cc.transform;
  while(T.parent!=null) T=T.parent;

Or depending on how objects are set up, go up parents until you get the correct tag, find a rigid body … .

The OnTriggerEnter will go to either the object with the Rigidbody or the object with the collider. I’m not sure which, but evidently its the one you aren’t using.