Camera Rotation Bug

The Camera seems to snap to a rotation of (0, 0, 0) constantly.
This still happens even after I’ve made a new project containing just a camera with the script and a cube, despite that I don’t think its the script.

public class CameraRotation : MonoBehaviour
{
    public CursorLockMode Curse;
    void Start()
    {
        Cursor.lockState = Curse;
    }

    void Update()
    {
        float XLook = Input.GetAxis("Mouse X");
        float YLook = Input.GetAxis("Mouse Y");

        YLook = Mathf.Clamp(YLook, -90, 90);

        Quaternion.AngleAxis(XLook, Vector3.up);
        Quaternion.AngleAxis(YLook, Vector3.left);

        transform.localEulerAngles = new Vector3(-YLook, XLook, 0);

    }
}

206211-unity-camera-bug.gif

soo, not sure what you are trying to do but here are some thing that you might have missed:

 Quaternion.AngleAxis(XLook, Vector3.up);
 Quaternion.AngleAxis(YLook, Vector3.left);

the 2 lines above currently do nothing. They just do a caluclation but you never catch the value that they return.

 //example:
 Quaternion calculationResult = Quaternion.AngleAxis(XLook, Vector3.up);

So in that sense it makes sense what you see as the AxisInput that you read from the mouse is the delta of the last frame. When the mouse in not moving the result will be zero and you set a zero rotation to your camera.

What you want to do instead is to rotate the camera by the delta you read from the mouse. So something like

   Camera.main.transform.rotate(x,y,z); 

might be what you need here

(not tested - just a pointer in the right direciton)