- Home /
Ship controls partially working
Firstly the ship is the main character, left and right (A, and D) roll the ship, but it does not roll then move in that direction. Does anyone know why it does not, how i could fix it? code below;
Turns out my description was terrible, I wanted it to move more like an airplane so when it rolls, it also yaws in that direction
var speed : int = 10; var maxSpeed : int = 100; var turnSpeed : int = 110 - 10 * speed;
function Update () {
translation = Input.GetAxis("Vertical") 2; if (Input.GetMouseButton(1)) { transform.Rotate(Input.GetAxis("Mouse Y") 1.5, 0, 0); }
transform.Translate(0.0, -translation, 0.0); speed = speed + 1; //cannot travel faster than maxSpeed
speed = Mathf.Clamp(speed, 0, maxSpeed);
transform.Rotate( 0, Input.GetAxis("Horizontal") Time.deltaTime turnSpeed, 0 );
if (Input.GetKey (KeyCode.Space)) { transform.Translate(0.0, translation, 0.0); }
if (Input.GetKey (KeyCode.LeftControl)) { transform.Translate(0.0, -translation, 0.0); }
}
Your answer
Follow this Question
Related Questions
finding pitch/roll/yaw from Quaternions 4 Answers
Camera pitch/yaw relative to plane 2 Answers
Problems getting PID system and rotations to work together. 0 Answers
pitch camera up and down... 1 Answer