- Home /
Activating child triggers?
In my level, various prefabs spawn that act as rooms. Inside the rooms there are trigger colliders that are children of the parent prefab. However, when the player object collides with them, nothing happens - it's as if unity hasn't recognized the collision at all.
Is this a bug/feature in Unity? Or am I doing doing something wrong in my scripting?
If a gameobject and it's parent both have colliders only the parent collider will be active in game...this might be the reason.
That is probably the reason... I'll see if I can work around it.
I'm fairly sure that's incorrect. Any children of a transform that has colliders are associated with the RigidBody of the parent.
You can check which RigidBody it is associated with by looking at collider.attachedRigidBody. The script that contains the OnTriggerEnter must be on the same GameObject as the RigidBody.
According to Collider script reference:
Note that trigger events are only sent if one of the colliders also has a rigidbody attached.
Your answer
Follow this Question
Related Questions
Make a simple tree 1 Answer
The name 'Joystick' does not denote a valid type ('not found') 2 Answers
Trouble with triggers and colliders 1 Answer
OnTrigger outside the trigger and collider gamobject 1 Answer
Enemy Attraction/Aggro 1 Answer