Can anyone help me my wheel collider code doesn't work

I have these coded for wheel coliders but they dont move when the code is used the vehicle just kinda vibrates but if i make the brake value 10 and the acelleration value 100 the vehicle will reverse only. and then a couple seconds later it just starts flipping wildly is ther anything wrong with this code:

    var speedDefault : float = 10;
var brakeDefault : float = 100;
function FixedUpdate () {
    if ( Input.GetAxis("Shoulder Axis") > 0.1){
        if (collider.motorTorque < 0 ){
            collider.brakeTorque = brakeDefault * Input.GetAxis("Shoulder Axis");
        }else{
            collider.motorTorque = speedDefault * Input.GetAxis("Shoulder Axis");
        }
    }

    if ( Input.GetAxis("Shoulder Axis") < -0.1){
        if (collider.motorTorque > 0 ){
            collider.brakeTorque = brakeDefault * Input.GetAxis("Shoulder Axis");
        }else{
            collider.motorTorque = speedDefault * Input.GetAxis("Shoulder Axis");
        }
    }
}

or could it be something else causing this to happen really strange like thanks to anyone who can help.

Nope had no effect at all.

1 Answer

1

Solved it turns out that rigid body error doesnt mean that i have to make my wheel colliders rigid bodys and attach them to my car with fixed joints.