Hello!
How do I create a button that, when pressed, makes the car go backwards?
My gas button works like this:
public void Gas ()
{
motorInputTouch = 1;
gasOn = true;
Debug.Log ("Gas");
wheelBR.brakeTorque = 0;
wheelBL.brakeTorque = 0;
// First gear
if (currentSpeed <= 150 && currentSpeed > -maxReverseSpeed && !braked) {
wheelBR.motorTorque = OneTorque * motorInputTouch;
wheelBL.motorTorque = OneTorque * motorInputTouch;
}
// Second gear
else if (currentSpeed <= 300 && currentSpeed > 150 && !braked) {
wheelBR.motorTorque = TwoTorque * motorInputTouch;
wheelBL.motorTorque = TwoTorque * motorInputTouch;
}
// Third gear
else if (currentSpeed <= 450 && currentSpeed > 300 && !braked) {
wheelBR.motorTorque = ThreeTorque * motorInputTouch;
wheelBL.motorTorque = ThreeTorque * motorInputTouch;
}
// Fourth gear
else if (currentSpeed > 450 && currentSpeed <= topSpeed && !braked) {
wheelBR.motorTorque = FourTorque * motorInputTouch;
wheelBL.motorTorque = FourTorque * motorInputTouch;
} else {
wheelBR.motorTorque = 0;
wheelBL.motorTorque = 0;
}
}