So I need that a ship move around the surface of a planet at a fixed height. And also rotate on Y axis following the mouse. The camera is 3rd person and follows the ship movement, but dont rotate on Y axis with the ship. My script does both things but when I start to move the ship, it starts to rotate on X and Z axis. I tried to use RigidBody constraits and it didn
t worked. This is my setup:
Planet centered at (0,0,0)
GameObject centered at (0,0,0)
GameObject(1) same position as the ship.
I have a script associated to GameObject for movement:
if (Input.GetKey(KeyCode.UpArrow))
transform.Rotate(new Vector3(2, 0, 0));
if (Input.GetKey(KeyCode.DownArrow))
transform.Rotate(new Vector3(-2, 0, 0));
if (Input.GetKey(KeyCode.RightArrow))
transform.Rotate(new Vector3(0, 0, -2));
if (Input.GetKey(KeyCode.LeftArrow))
transform.Rotate(new Vector3(0, 0, 2));
And a script associated to the ship: