I am using this script for my space-plane thing.
var Throttle = 60;
var Brake = -60;
function FixedUpdate () {
if (Input.GetKey(KeyCode.Mouse0)) { // space is pressed - apply force here}
rigidbody.AddRelativeForce(0,Throttle,0);
print("Throttle");
}
if (Input.GetKey (KeyCode.Mouse1)) {
rigidbody.AddRelativeForce(0,Brake,0);
print("Brake");
}
if (Input.GetKey (KeyCode.A)) {
rigidbody.AddTorque(0,0,0.01 * Throttle);
rigidbody.AddRelativeForce(0,0,0.4);
}
if (Input.GetKey (KeyCode.D)) {
rigidbody.AddTorque(0,0,-0.01 * Throttle);
}
if (Input.GetKey (KeyCode.W)) {
rigidbody.AddRelativeTorque(Vector3.right * 2);
}
if (Input.GetKey (KeyCode.S)) {
rigidbody.AddRelativeTorque(-Vector3.right * 2);
}
}
It works well until it starts to turn, in which the plane cannot level out, and the left and right will start doing the opposites of what they should. Why?