I don’t really know how to describe my problem, I’ve looked at a few other “Clamp not working” threads and none seem to be my specific problem. I’m trying to clamp my camera on the Y-axis, standard stuff for a first person game. But whenever I go to test it, it doesn’t let me move my camera vertically. Here is my code :
{
public Transform cam;
public float mouseSensitivity;
private float horizontal;
private float vertical;
private float mouseHorizontal;
private float mouseVertical;
private Vector3 velocity;
float mouseVerticalt = 0;
private void Update()
{
PlayerInput();
mouseVerticalt -= mouseVertical;
transform.Rotate(Vector3.up * mouseHorizontal);
cam.transform.localRotation = Quaternion.Euler(mouseVerticalt, 0f, 0f);
mouseVerticalt = Mathf.Clamp(mouseVerticalt, -90f, 90f);
Debug.Log("Clamp" + mouseVerticalt);
Debug.Log("Vertical" + mouseVertical);
}
My camera is parented to my player object if that helps, and assigned in the inspector.