In my 3rd person game, I’m using this to rotate the plaxer and look around:
public void Rotate()
{
float horizontalRotation = Input.GetAxis("Mouse X");
float verticalRotation = Input.GetAxis("Mouse Y");
transform.Rotate(0, horizontalRotation * mouseSensitivity, 0);
cameraHolder.Rotate(verticalRotation * mouseSensitivity, 0, 0);
Vector3 currentRotation = cameraHolder.localEulerAngles;
if (currentRotation.x > 180) currentRotation.x -= 360;
currentRotation.x = Mathf.Clamp(currentRotation.x, upLimit, downLimit);
cameraHolder.localRotation = Quaternion.Euler(currentRotation);
}
Now when looking up and down, the camera still pivots on its own center without moving up and down.
I’d actually prefer the camera pivot to be the player’s head, effectively having the head in the center of the frame all the time wit hthe camera moving closer to the ground when looking up and moving higher up when looking down.
…how do I do that?