I'm not exactly sure what you're trying to do, though I think you're trying to use some convoluted methods for getting your object to move. I tried deciphering your code and came up with:
var Throttle = 60;
var Brake = -60;
function FixedUpdate () {
if(Input.GetMouseButton(0)){ // go forward?
rigidbody.AddForce (Vector3.forward * Throttle);
print("Throttle");
}
if(Input.GetMouseButton(1)){ // Slow down or go backwards?
rigidbody.AddForce (Vector3.forward * Brake);
print("Brake");
}
if (Input.GetKeyDown ("a")){ // go left?
rigidbody.AddForce (Vector3.right * Throttle * 10);
}
if (Input.GetKeyDown ("d")){ // go right?
rigidbody.AddForce (Vector3.right * -Throttle * 10);
}
if (Input.GetKeyDown ("w")){ // go up?
rigidbody.AddForce (Vector3.up * Throttle);
}
if (Input.GetKeyDown ("s")){ // go down?
rigidbody.AddForce (Vector3.up * -Throttle);
}
}
... which I THINK at least does what your code is intended to do... tho, if you're trying to make a flight sim, this is probably not going to work very smoothly for that. If you look around the web, you'll find some folks who have posted decent versions of flight scripts, which might be a good place to start...
↧