Camera Angle Conflict Pitch & Pan...I'm Lost

Hello All,

I'm trying to customize the Smooth-Follow camera to my needs but am having trouble understanding the camera angles. My script problems is as follows:

var pitch = 30;
 function Update(){
  transform.Rotate(Vector3(Input.GetAxis("Mouse Y"), Input.GetAxis("Mouse X"), 0) * Time.deltaTime * XYmousespeed);

This allows the camera to pan left and right via the mouse and works well with the camera following. The problem I'm having is setting the camera to pitch or tilt.

I added this to no avail:

transform.Rotate (pitch, 0, 0);

Obviously these two instructions conflict with each other but I cannot figure out how to make them "get along". I've tried everything I can think of but no matter what I do, I cannot get the first axis (x, I believe) to pan AND tilt - only one or the other. Any help would be greatly appreciated. Thank you for your time.

Ok, some notes in general: Input.GetAxis("Mouse ...") returns already delta values. That means it returns the amount of movement that happend in this frame. Don't use Time.deltaTime here. It would reduce the movement at high framerates and boost it on low framerates.

Now we fix the rotation. Transform.Rotate() rotates the object relative! If you call Rotate(0,0,0) nothing would change. If relativeTo is not set explicit to Space.World it defaults to Space.Self. That means you rotate you object relative to your local space.

I guess you want to rotate the camera around global y-axis and around local x-axis. This can be done with two calls to Rotate():

transform.Rotate(0, Input.GetAxis("Mouse X")*XYmousespeed, 0 ,Space.World);
transform.Rotate(Input.GetAxis("Mouse Y")*XYmousespeed, 0, 0 ,Space.Self);

An alternative would be to seperate both rotations and generate the Quaternions directly:

var Rot : Vector3 = transform.localEulerAngles;
Rot.y += Input.GetAxis("Mouse X") * RotationSpeed;
Rot.x += Input.GetAxis("Mouse Y") * RotationSpeed;
transform.localRotation = Quaternion.Euler(Rot);

ps. Don't set eulerAngles directly. They have to be within [0-360] and if you set them outside this range you will get errors.