- Home /
Why does Input.GetAxis("Mouse X/Y") result in inverted movement?
I've written a script that gets the X and Y movement from the mouse and translates that into rotation in the x & y axis.
 if (isMouseLookMode == true)
 {
      mouseMovement.x = mouseLookSensitivity * Input.GetAxis ("Mouse X");
      mouseMovement.y = -mouseLookSensitivity * Input.GetAxis ("Mouse Y");
      transform.Rotate (mouseMovement.y, mouseMovement.x, 0);
 }
However, I had to swap the x with the y values, and make the y value negative to achieve the same mouse rotation as in Unity (ie. holding down right mouse button rotates the viewport).
Why is this the case?
Answer by tanoshimi · Aug 08, 2015 at 10:11 PM
Because that's what you'd expect...? Moving the mouse right leads to a clockwise rotation about the y-axis, moving the mouse up leads to a anti-clockwise rotation about the x-axis. I'm not sure what the problem is, but it sounds like you don't understand the parameters to transform.Rotate: http://docs.unity3d.com/ScriptReference/Transform.Rotate.html
Your answer
 
 
             Follow this Question
Related Questions
Geometry Wars game experience in Unity 2 Answers
How can I pause the "Mouse Look" script when I pause my game? 2 Answers
turn mouse look on and off using the 'm' key 2 Answers
Problem with the standard mouselook script 0 Answers
MouseY always enabled? 3 Answers
 koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                