How to Rotate the camera up and down using mouse input.

My Code So Far:

float mouse = Input.GetAxis(“Mouse Y”);
Vector3 look = new Vector3(0, 0, mouse * 10);
transform.Rotate(look);

Hi,

Moving the camera up and down, means rotating around X axis.

Notice that ‘Input.GetAxis(“MouseY”)’ returns positive values whenever you move your mouse up. And negative values whenever you move it down. But, if you want to look Up with the camera, the rotation on the X axis goes down, and whenever you look down, the x value on rotation increases.

So, you have to invert whatever you recieve in your mouse variable:

float mouse = Input.GetAxis("Mouse Y");
transform.Rotate(new Vector3(-mouse*sensitivity,0,0));

You should do this in the Update method, so it gets automatically calculated every frame.

Hope it helps.

This video explains how to orbit the camera in different directions using the mouse movement and avoid the unwanted tilt effect in Unity.link text