I’m trying to rotate my main camera using keyboard and scroll using the mouse wheel. Just rotation or just zooming work fine, but when you do both the camera starts rotating along the x, y, and z axes instead of just the y.
//Rotate clockwise
if (Input.GetKey(KeyCode.Q))
{
Camera.main.transform.Rotate(new Vector3(0, 2, 0));
}
//Rotate counterclockwise
else if (Input.GetKey(KeyCode.E))
{
Camera.main.transform.Rotate(new Vector3(0, -2, 0));
}
//Scroll down and zoom out
if ((Input.GetAxis("Mouse ScrollWheel") < 0f) && (Camera.main.transform.position.y < 15))
{
Camera.main.transform.Translate(new Vector3(0, 1, 0));
Camera.main.transform.Rotate(new Vector3(3, 0, 0));
}
//Scroll up and zoom in
if ((Input.GetAxis("Mouse ScrollWheel") > 0f) && (Camera.main.transform.position.y > 2))
{
Camera.main.transform.Translate(new Vector3(0, -1, 0));
Camera.main.transform.Rotate(new Vector3(-3, 0, 0));
}