ignoring collisions with a parent object

i have this script `Physics.IgnoreCollision(instantiatedProjectile.collider, collider);` on a script that instantiates a bullet. the gun is a child in a parent object which has a collider.

how to i get the bullet to ignore the parents collider, can i use the above code?

2 Answers

2

Layer based collision detection, introduced in Unity 3, is what you are looking for.

Take a look in the Unity documentation

what if there's two identical objects, each with a child collider that detects each the other parent, but not its own, Ie. parent1>child2 parent2>child2 child1 should detect parent2 but not parent1

–

also try

Physics.IgnoreCollision(instantiatedProjectile.collider, transform.root.collider); 

You want it to ignore the parent collider.

thanks this wont work for me tho as parent is also a child of the root. (i realize i hadn't detailed this)

–