Yaw And Pitch Switched When Rolled To The Side
I'm making a game with a free camera and when the player rolls left or right, yaw and pitch get messed up. More Specifically, when rolled 90 degrees, moving the mouse up or down makes the camera look left and right, and vice-versa. This happens to all degrees but is most noticeable at 90. I would like the rotation to be completely local. Here's the bulk of the code:
private float verticalMouse;
private float horizontalMouse;
public static Vector3 viewRotation;
void View () {
verticalMouse = Input.GetAxis("Mouse X");
horizontalMouse = Input.GetAxis("Mouse Y");
viewRotation.y += verticalMouse;
viewRotation.x -= horizontalMouse;
if (Input.GetKey(KeyCode.Q)) {
viewRotation.z += 0.5f;
} else if (Input.GetKey(KeyCode.E)) {
viewRotation.z -= 0.5f;
}
gameObject.transform.localEulerAngles = viewRotation;
}
Your answer
Follow this Question
Related Questions
Anyone know how to rotate an object using yaw, pitch, roll of the HTC VIVE and SteamVR? 0 Answers
How to keep the same yaw(right/left) and pitch(up/down) controls rotation as I roll ? 0 Answers
Unwanted up/down (pitch) movement when tilting 0 Answers
How to add force to dice so it rolls all over the table and it turns in while being thrown 1 Answer
I can't set AudioSource pitch. It said "Value cannot be null" 0 Answers