Mouse Axis opposite when upsidedown

Hi,

I am using the mouse-look script that comes with unity to control a spaceship, except when the ship is upside down the control gets messed up, when i move the mouse left the ship turn right and vice versa.

Does any1 have a solution to this? I searched the forums but couldn’t find a post similar and i tried using this code

transform.Rotate(0, Input.GetAxis("Mouse X") * sensitivityY, 0);
		transform.Rotate(Input.GetAxis("Mouse Y") * -sensitivityX, 0, 0);

but that also effects the roll factor, which i do not want.

Any help would be great thanks!

One solution is to check to see if you’re upside down. If you are, just invert left and right (mult by -1).

To determine if you’re upside down, get the dot product of the ship’s Up Vector and the world Up Vector. If the dot product is less than zero, the ship is upside down.

Thanks guys, i had previously tried to detect if it was upside down but didn’t think of using the dot factor.

thanks again.