- Home /
how do i change the wheel collider stiffness with a script?
In my game, you can upgrade the tires. the real difference between tires is the stiffness on the wheel collider. I want the stiffness of the wheel to be changed by a script, but when I use the WheelCollider.forwardfriction.stifness , I get an error. I think you can also use WheelFrictioCurve. ive tried, but cant see the difference. how do i change the wheel collider stiffness with a script?
error CS1612: Cannot modify a value type return value of `UnityEngine.WheelCollider.forwardFriction'. Consider storing the value in a temporary variable
Answer by Sir-Irk · Nov 19, 2014 at 04:39 AM
Try this:
//You may also want to change wheelCollider.sidewaysFriction
//BTW, the "Stiffness Factor" in the editor only seems to represent sidewaysFriction.stiffness
WheelFrictionCurve frictionCurve = wheelCollider.forwardFriction;
frictionCurve.stiffness = 5f;//whatver you want
wheelCollider.forwardFriction = frictionCurve;
Your answer
Follow this Question
Related Questions
Distribute terrain in zones 3 Answers
Multiple Cars not working 1 Answer
How do I load a new scene based on current scene? 3 Answers
Is it possible to change keyboard input inGame 1 Answer
Unity hardware changed event 0 Answers