- Home /
Checking Child Triggers in Parent Script
I've got a case where I have a gameobject with a trigger that is a child of a gameobject that has a script attached to it.
What I'd like to know is, in the script of the parent, is there any way to use OnTriggerEnter/OnTriggerExit to check the trigger on the child object? Though I could attach a script to the child to check this which then messages the parent, I feel like it would be much cleaner if I could check this in the script already attached to the parent.
Thanks!
Answer by Jessy · Feb 28, 2011 at 07:07 PM
Yes. Put a kinematic rigidbody on the parent. Typically this is done when using compound colliders, but it works the same when there's only one collider.
It doesn't seem to work for me. I had to disable the isTrigger option of the box collider attached to my child object. Only then OnTriggerEnter on the parent gameobject is working.
The other object to which this game object is colliding is also a trigger with rigidbody is$$anonymous$$inematic true.
It doesn't work for me either, no matter how I set up the parent (RigidBody always kinematic, collider disabled, enabled, enabled and trigger) or the child (collider is trigger or not). What am I missing?
Your answer