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.
I've updated the code, but it throws an error: var level : GameObject; var wheels_ignore : GameObject; function OnCollisionEnter(collision:Collision) { static function IgnoreLayerCollision (level : int, wheels_ignore : int, ignore : bool = true) : void; { if(collision.gameObject.tag == "carphysics") { FrontLeftWheel.sidewaysFriction.stiffness=0; FrontRightWheel.sidewaysFriction.stiffness=0; BackLeftWheel.sidewaysFriction.stiffness=0; BackRightWheel.sidewaysFriction.stiffness=0; }}} What do I do now? Sorry, I'm not at my most awake moment right now :P
– Majatek