FPS rotate camera

Thanks for the help in advance. I am developing an FPS that has some gravity effects, but I am having a hard time getting the main camera to rotate; so that when the player wants to stand on a different gravity plane the camera will rotate so that the perspective looks like a normal FPS. I currently have a ray being traced out from my character and recognizing planes you can switch gravity by clicking the mouse button on them. How do I access the main camera an perform the transform? I realize I need to change the mouse look script to accommodate this new perspective, but I want the player control of the character to stop for about 3 seconds while the camera slowly rotates to the new perspective.

Ok, since you have a mouse look script attached to your camera, all you have to do is move the position of your camera, since the rotations will be handled by the mouse look script.

Use something like this in a script attached to your camera:

var speed:float = 1.0; // camera animation speed

function moveIt(){

  var endPosX:float = 2.0; // end x position of camera
  var endPosY:float = 3.0; // end y position of camera
  var endPosZ:float = 4.0; // end z position of camera
  ...
  ...
  ...
  xPos = transform.position.x;
  yPos = transform.position.y;
  zPos = transform.position.z;

  xPos = Mathf.Lerp(xPos, endPosX, Time.deltaTime * speed) // move X

  yPos = Mathf.Lerp(yPos, endPosY, Time.deltaTime * speed) // move Y

  zPos = Mathf.Lerp(zPos, endPosZ, Time.deltaTime * speed) // move Z

}

Then just call moveIt() when you want to change the position of the camera.

OK, let me clarify what Im trying to do. I have a game room that is a cube at the moment. I am standing on the “floor” so gravity is going in the -y direction. I want to be able to click a button while looking at the wall in front of me , and have the camera rotate to have that be the “floor” so that gravity is now in the -z direction and the perspective remains as if I am walking on a “floor”, with the plane the character is dropping against is the ground.
I have the gravity effects working, just having a problem getting the camera to track correctly, ie now that I am on the new “ground” moving the mouse left and right and forward and backward behaves like all other fps.

Heres a snippet of the pertinent info from my current mouselook:

void Update ()
	{
		//axes == RotationAxes.MouseXAndY)
		if (direction == 0)
		{
			// Read the mouse input axis
			rotationX += Input.GetAxis("Mouse X") * sensitivityX;
			rotationY += Input.GetAxis("Mouse Y") * sensitivityY;

			rotationX = ClampAngle (rotationX, minimumX, maximumX);
			rotationY = ClampAngle (rotationY, minimumY, maximumY);
			
			Quaternion xQuaternion = Quaternion.AngleAxis (rotationX, Vector3.up);
			Quaternion yQuaternion = Quaternion.AngleAxis (rotationY, Vector3.left);
			
			transform.localRotation = originalRotation * xQuaternion * yQuaternion;
		}
		
		if (direction == 1)
		{
			// Read the mouse input axis
			rotationX += Input.GetAxis("Mouse X") * sensitivityX;
			rotationY += Input.GetAxis("Mouse Y") * sensitivityY;

			rotationX = ClampAngle (rotationX, minimumX, maximumX);
			rotationY = ClampAngle (rotationY, minimumY, maximumY);
			
			Quaternion xQuaternion = Quaternion.AngleAxis (rotationX, Vector3.forward);
			Quaternion yQuaternion = Quaternion.AngleAxis (rotationY, Vector3.left);
			
			transform.localRotation = originalRotation * xQuaternion * yQuaternion;
		}

At the moment, you are using Quaternion.AngleAxis with Vector3.up and Vector3.left as the rotation axes. These are world directions, but you can get the player’s local Y and X axes using transform.up and transform.right, eg:-

Quaternion xQuaternion = Quaternion.AngleAxis (rotationX, player.transform.up);