- Home /
How to disable children triggering the collision event of parent.
Using "function OnCollisionEnter(collider:Collision)" returns a trigger with both my vehicle's body AND the wheels when the entire object collides with the terrain - Which is not what I want, because on collision with a solid, I'm reducing the friction of the wheels. If the function triggers because the wheels collide with the ground (and are constantly in contact with the terrain), it ruins what I'm trying to achieve and my vehicle ends up sliding all over the place, permanently.
Is there any way to disable the children from triggering the event? I've got the Javascript running in my parent object (that's at the top of the hierarchy - Vehicle wheels stored inside).
As a side note, I've grouped the terrain colliders and the wheel colliders into their own layers, but I have no idea how to utilize them, if I could.
Answer by Teare · Apr 23, 2011 at 08:30 PM
you want to add tag to the body, called "Body" or something and then filter it out in the collision function using:
function OnCollisionEnter (collider:Collision){
if(collider.tag == "Body"){
//your function here