Hi,
I've searched everywhere but didnt get an answer for this, how do I limit the speed of my car? my if statement doesnt work in `function Update()`.
My code:
function Update() {
if (currentSpeed > topSpeed) {
maxTorque = 0;
} else if (currentSpeed <= topSpeed) {
maxTorque = maxCurrentTorque;
} else {
Decel();
}
}
maxTorque is my variable to hold the motorTorque of my WheelColliders, and maxCurrentTorque is a variable whose value is taken by the maxTorque after the speed is below the limit.
Thanks
↧