- Home /
Decreasing wheel friction with velocity
I want to have my car wheels to have less sideways friction at higher speeds, how do i do this? this is the code i have so far... but it doesn't work.
var slip = 0.022 - (rigidbody.velocity.magnitude / 150);
BackRightWheel.WheelHit.sidewaysSlip = slip;
Answer by spinaljack · Jul 14, 2010 at 05:50 PM
I'd change your code to:
var slip : float;
BackRightWheel.sidewaysFriction.stiffness = slip;
Also I'd clamp the slip value to make sure it never reaches 0 or some other minimum value.
To use math clamp you do this:
slip = Mathf.Clamp(slip,min,max)
or
slip = Mathf.Clamp(slip,0.001,0.022);
If you wanted a smooth curve instead of a linear line you can use this formula instead:
slip = 0.001 + 0.022/(rigidbody.velocity.magnitude+1)
Doesn' work... i get an error of : Assets/PlayerCar_Script.js(49,16): BCE0019: 'WheelHit' is not a member of 'UnityEngine.WheelCollider'.
ins$$anonymous$$d of this: var slip = 0.022 - (rigidbody.velocity.magnitude / 150);, is there a better way to reduce it, but not too far? cos this goes into $$anonymous$$us numbers.