- Home /
Problem using rotation and Rotate
I have a top down game I am trying to implement and I am having some issues with the movement. I have A,D set to move the player along the horizontal axis. When moving along this axis the ship has a slight tilt depending on which way it is moving. The player then returns to their normal position after key release. I also have E,Q set to rotate the player around the y axis freely. I have both of these currently working however if a user pressed both a horizontal button and a rotation button like 'A+E' it sends the ship spinning off around the y axis. Any ideas on how to fix this?
transform.position = new Vector3(Mathf.Clamp(transform.position.x, -500, 500),0.0f,Mathf.Clamp(transform.position.z,-500,500));
// This tilts the ship along the z axis
transform.localEulerAngles= Vector3(0,0,Input.GetAxis("Horizontal") * -tilt);
// This rotates the ship around the y axis
transform.Rotate(0.0f, Input.GetAxis("Rotate"), 0.0f);
Answer by Shrikky23 · Jan 27, 2014 at 06:17 AM
The ship is tilting because of ur Z movements. If you want just a horizontal movement, make changes only to X and not Y or Z