Remove all forces on a wheel Collider

Hi all,

I have a simple vehicle that I wish to remove all forces from when I respawn it. I'm using 4 wheel colliders. Forward force is applied by using wheelCollider.motorTorque and braking force is done by brakeTorque. I can get the vehicle to respawn and set it's velocity to zero, but there's often some residual forces working on the wheels. From what I've read, the WheelCollider.rpm is a read only function. Is there any way to instantly set it's WheelCollider.rpm == 0?

You can instantly force the rpm to zero by setting an infinite braking torque:

WheelCollider.brakeTorque = Mathf.Infinity;

However, those residual forces don't come from the rpm. For instance, when riding over a bump the first frame the wheel interpolates the bump there's no force applied. The next frame, as result of the calculations, the proper force is applied to the rigidbody. If a respawn occurs exactly in the middle, then the force will be applied right after respawning.

You should be able to disable the effects of those occasional forces by briefly making the rigidbody as kinematic after respawning. Something like this:

function FixedUpdate()
    // (if the vehicle has been respanwed this frame, 
    //        then a variable respawned is set to true)

    if (respawned)
        wheelCol.brakeTorke = Mathf.Infinity;   // Repeat for all wheelcolliders
        rigidbody.isKinematic = true;
        respawned = false;
        rigidbody.isKinematic = false;

        // (do the torque calculations here as usual)