I tried to move a aeroplane for my game using this following script below
var horizontalSpeed : float = 2.0;
var verticalSpeed : float = 2.0;
function FixedUpdate () {
Screen.showCursor = false; //hide the mouse cursor in game
// Get the mouse delta. This is not in the range -1...1
var h : float = horizontalSpeed * Input.GetAxis ("Mouse X");
var v : float = verticalSpeed * Input.GetAxis ("Mouse Y");
transform.Rotate (-v, h, 0);
}
it is used together with the following script
var speed = 20;
function Update () {
if (Input.GetKey(KeyCode.UpArrow)){
speed +=2;
}
if (Input.GetKey(KeyCode.DownArrow)){
speed -=2;
}
transform.Translate(Vector3.forward *speed* Time.deltaTime);
}
the up/down arrow keys increase and decrease the speed, problem is it does not work excatly as i expect does anyone have any input or suggestions for the code
my objective is to get the plane to move up, down, right, left
but the ‘left side to right side’ tilt of the plane (Roll), is controlled by the left and right arrow keys, but the plane keeps turning upside down after moveing the mouse for a while
I need it to turn where i point, but (the roll is done from the left/right keys), what is going wrong here, (I am new to unity script, but i learnt java and javascript for web development)