- Home /
How to make Parent object's script ignore trigger component on children
To immerse yourself into how I want to make it, I'm having Character controller GameObject which has trigger component which used to detect stuff such as ladder and so on, and there's also children GameObject attached, with it's own script which acts as "HitZone" to check if attack has hit any enemy in front of it. But, OnTriggerEnter2D function inside parent's script also reacts to Children's trigger component.
Any solution or workaround is welcome.
Answer by Bunny83 · Oct 06, 2014 at 04:34 PM
Just place them on different layers and setup the collision matrix.
For this to work you also need to check the layer in your OnTriggerEnter.
Any RigidBody will treat all of its children colliders as part of itself. But you can distinguish between them by name, tag or layer checking.
Could you post example of how could I check the layer inside OnTriggerEnter? I couldn't find example online nor documentation online D:
Edit: Never$$anonymous$$d, it worked without even checking the layer. Thanks to you both! :D
Your answer

Follow this Question
Related Questions
Detect trigger touching another trigger? 1 Answer
Why is my Collider Broken? 0 Answers
OnTriggerEnter question 1 Answer
collider vs collider2d 1 Answer
Triggers are not detecting colliders from other game objects in Unity version 5.2.2f1? 0 Answers