I made a “car” (a box) and attached 4 wheelcolliders to it, it accelerates like it should if I add mototorque to the wheels. But it’s doesn’t decelerate.
var maxTorque:float = 600;
var maxBrakeTorque:float = 6000;
...
if(accelerating)
{
leftWheel.motorTorque = maxTorque;
rightWheel.motorTorque = maxTorque;
leftWheel.brakeTorque = 0;
rightWheel.brakeTorque = 0;
rearleftWheel.brakeTorque = 0;
rearrightWheel.brakeTorque = 0;
}
else if(braking)
{
leftWheel.motorTorque = 0;
rightWheel.motorTorque = 0;
rearleftWheel.motorTorque = 0;
rearrightWheel.motorTorque = 0;
leftWheel.brakeTorque = maxBrakeTorque;
rightWheel.brakeTorque = maxBrakeTorque;
rearleftWheel.brakeTorque = maxBrakeTorque;
rearrightWheel.brakeTorque = maxBrakeTorque;
}
If the car is “braking” it doesn’t accelerate anymore, so that’s working, but the speed isn’t dropping at all.