First Person Camera Bug,When I turn the camera it is bumpy.

When I turn the camera sometimes works perfectly fine, sometimes it makes huge jumps. I have been looking at this for a solid hour and cant seem to fix it (I am newish to Unity). Here is my code -

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class mouseLook : MonoBehaviour
{

    public float sensX;
    public float sensY;

    public Transform orientation;

    float xRotation;
    float yRotation;

    // Start is called before the first frame update
    void Start()
    {
        Cursor.lockState = CursorLockMode.Locked;
        Cursor.visible = false;
    }

    // Update is called once per frame
    void Update()
    {
        float mouseX = Input.GetAxisRaw("Mouse X") * Time.deltaTime * sensX;
        float mouseY = Input.GetAxisRaw("Mouse Y") * Time.deltaTime * sensY;

        yRotation += mouseX;

        xRotation -= mouseY;
        xRotation = Mathf.Clamp(xRotation, -90f, 90f);

        transform.rotation = Quaternion.Euler(xRotation, yRotation, 0);
        orientation.rotation = Quaternion.Euler(0, yRotation, 0);
    }
}

,When I turn using the script below, sometimes it turns correctly and sometimes it makes jumps of varying sizes. I have been looking at this for at least 45 minutes and I cant seem to figure it out (Im newish to unity).

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class mouseLook : MonoBehaviour
{

    public float sensX;
    public float sensY;

    public Transform orientation;

    float xRotation;
    float yRotation;

    // Start is called before the first frame update
    void Start()
    {
        Cursor.lockState = CursorLockMode.Locked;
        Cursor.visible = false;
    }

    // Update is called once per frame
    void Update()
    {
        float mouseX = Input.GetAxisRaw("Mouse X") * Time.deltaTime * sensX;
        float mouseY = Input.GetAxisRaw("Mouse Y") * Time.deltaTime * sensY;

        yRotation += mouseX;

        xRotation -= mouseY;
        xRotation = Mathf.Clamp(xRotation, -90f, 90f);

        transform.rotation = Quaternion.Euler(xRotation, yRotation, 0);
        orientation.rotation = Quaternion.Euler(0, yRotation, 0);
    }
}

Edit: Lower frame rate seems to lessen the effect, but not make it disappear completely.

Don’t multiply the Mouse X or Mouse Y axis by Time.deltaTime. Normally, when you are working with a speed in units per second, you would be correct to multiply by delta time when you are doing things within Update(), as this will compensate for variable frame rates (length of time since last time update was called). However, with Mouse X and Mouse Y, this is already a measurement of how far the mouse moved since the last frame. It’s not expressed as a speed in units/second, just how far the mouse moved since last frame, so it is already frame rate dependant, and multiplying by delta time will give you undesirable/arbitrary results.

Didn’t read your post, but did you try FixedUpdate instead?