Simple child collider question.

I have a rigidbody box which moves around, and I have two “feeler” boxes in front of it to detect collisions - just like an insect’s antenna. The feelers are children of the main box, and IsTrigger is activated on each one. The feelers are named “LeftFeeler” and “RightFeeler”.

When one of the feelers hits a wall, I want it to rotate the box away(EDIT: but the feelers themselves are ONLY triggers, not physical objects). The problem is that I can’t determine which feeler is colliding, because I don’t know how to access them.

I put the same script on both feelers, and I tried this:

     void OnTriggerEnter(){
           Debug.Log (this.gameObject.name);
     }

But that just gives me the name of the parent box. How do I access the child that had the collision?

Colliders on children act as a single compound collider on the parent, by design. If you need separate collisions, they’d have to be separate objects. You can have a script on them that mirrors the “parent”'s actions in order to still effectively work as children.

–Eric

Thank you Eric, but I didn’t phrase my question correctly.

The feelers do not physically interact with anything, they are only triggers which are used to gently rotate the main body left or right to avoid running into walls.

The same script is running on each feeler, so when they collide with a wall, I need the script to know if it is attached to the “RightFeeler” or the “LeftFeeler” - so that I know which way to turn the main body.