- Home /
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.
Try making the brake/acceleration a negative number, see if that works... I highly doubt it, but you never know =).
Answer by riordanw · Apr 24, 2011 at 10:06 PM
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.