- Home /
How to NOT detect child collider
I have gameObject with my script, Rigidbody2D and BoxCollider2D. This object has child with BoxCollider2D (trigger). My script on parent object has OnTriggerEnter2D and OnTriggerExit2D. When parent or (!) child object's collider enters some other BoxCollider2D script detects collision. I need to detect only parent's collider collisions. Any suggestions?
Answer by Kaart · May 05, 2020 at 08:44 PM
You should use layers for your collision. Using layers you can specify which objects interact with each other. See the Unity manual for help. https://docs.unity3d.com/Manual/LayerBasedCollision.html
Answer by khiem06072007 · Sep 15, 2021 at 02:35 AM
I Get the same problem but here's the deal: My laser gameObject should be colliding with the Enemy normally, but they as a child of the Player, shouldn't collide with the enemy, (to detect if the player is hit) How can I do this? Or the only solution is to get the laser as a child of a temporary GameObject
umm the language here is a bit confusing, can you explain a bit more?
Your answer
Follow this Question
Related Questions
{java} so I want to enable/disable child objects through a parent script 2d 1 Answer
Collision with instantiated non-moving objects. 1 Answer
OnTriggerExit2D Does not work 1 Answer
Intercept Collider 2D/Collision2D events with a single script on scene 0 Answers
OnTriggerEnter2D working but OnTriggerExit2D never called 0 Answers