Logical Camera errors...

Ok, so im having this error with my Camera script… I know what the issue is juts not how to solve it. It orbits around the player, and if i orbit right, and then up a bit and then right again, it starts orbiting diagonally.

23614-1.png
this top view diagram shows the degree at which it can rotate around the player. So a full 360°.

23615-2.png
this front view diagram shows the degree at which it can rotate up and downwards whilst looking at the player. about 40°…

alt text
as you can see this is what is occurring if i rotate right then up then right. If i do that i just want it to continue on a ‘locked’ axis.

	if (Input.GetKey(KeyCode.LeftArrow)) {
			transform.Rotate(0,Time.deltaTime * 100,0);
		}
					
		else if (Input.GetKey(KeyCode.RightArrow)) {
			transform.Rotate(0,Time.deltaTime * -100,0);
		}	
		
		else if (Input.GetKey(KeyCode.UpArrow)) {
			transform.Rotate(Time.deltaTime * 100,0,0);
		}
					
		else if (Input.GetKey(KeyCode.DownArrow)) {
			transform.Rotate(Time.deltaTime * -100,0,0);
		}

sorry if i havent explained it properly its hard. hopefully the pictures give you guys some idea of whats occurring.

I don’t understand 100%, but it seems to me that this happens because you are rotating the camera using local axis rather than world. Try specifying Space.World as the last parameter in your Rotate statements, see:

e.g.

 if (Input.GetKey(KeyCode.LeftArrow)) {
transform.Rotate(0,Time.deltaTime * 100,0, Space.World);
}