Hey unityAnswers, I've been trying to make it so that my car (which has wheel childrens) to set wheel friction stiffness to zero on collision with whatever terrain - But each time I set the code to respond "OnCollisionEnter(collision:Collision)", not only does the car collide with the terrain, but the wheels too! So the event triggers even when the wheels collide with the terrain. D=
Is there a way to exclude a Rigidbody's children except for it's own collider to check collisions against terrain?
My current code:
function OnCollisionEnter(collision:Collision)
{
FrontLeftWheel.sidewaysFriction.stiffness=0;
FrontRightWheel.sidewaysFriction.stiffness=0;
BackLeftWheel.sidewaysFriction.stiffness=0;
BackRightWheel.sidewaysFriction.stiffness=0;
}
I understand there's a function called "if(collision.gameObject.tag == "layertag")" but I have no idea how to implement it, or to achieve the results that I would like to come up with, outlined above.