- Home /
Selectively detecting collisions with IsTrigger() and multiple CollisionBoxes
I have a prefab with multiple collision boxes, and on the highest level of it I have a script using IsTrigger() to detect collisions, however I need to only detect collision on one of the boxes. Is there a way to do this?
I'm not sure I understand what you mean. Collisions are detected on a collider basis. Collision with a child object will not inherently messages to the parent and vice versa. You would have to write code to specifically handle such situations. If the script is attached to the object you need to detect collisions on everything should work just fine.
That's weird because the everything looks like the collider in children is also triggering the OnTriggerStay in the parent. It's probably some tiny code mistake I'll find when I have more sleep, but it isn't looking that way.
If the collider on the child object hits the parent object collider it will trigger. So if your object has two colliders that overlap yhe OnTriggerStay is constantly running. I thought you meant that you had one object parented to another and they did not touch.
The collider on the child and parent object are not overlapping. The collider in the child is colliding with an outside collider and the OnTriggerStay is getting activated in the parent.
Interesting. I'll try to replicate this today and I'll share my findings.
Your answer
![](https://koobas.hobune.stream/wayback/20220613115516im_/https://answers.unity.com/themes/thub/images/avi.jpg)