time.deltatime makes camera jitter

As stated above, when I use time.deltatime in my first-person camera controller script, it makes the camera jitter very badly, but when I take it out, the camera works fine.

Of course, I want to keep time.deltatime in the script to avoid fps issues.

This problem only occurs on the new version of unity (2019.3.13f1). When I create a new project on older versions of unity and use the same script on a new object, the script works perfectly fine. It also works when I restart unity but if I edit the script, the camera starts to jitter again.

And this only seems to happen in the editor. When I build and run the game, the problem is gone.

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

public class fpsController : MonoBehaviour
{
    public Transform playerTF;
    public Rigidbody playerRB;

    public float sens = 5;

    float xRotation = 0f;

    private void Start()
    {
        Cursor.lockState = CursorLockMode.Locked;
    }

    private void FixedUpdate()
    {
        float mouseX = Input.GetAxis("Mouse X") * sens * Time.deltaTime;
        float mouseY = Input.GetAxis("Mouse Y") * sens * Time.deltaTime;

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

        transform.localRotation = Quaternion.Euler(xRotation, 0, 0);
        playerTF.Rotate(Vector3.up, mouseX);
    }
}

Thanks in advance.

I figured it out.

The problem was caused by my frame rate. The camera lagged when the fps dropped below 30fps. So I locked the fps to 300 and it fixed the problem.

Application.targetFrameRate = 300;

My pc keeps dropping to 30fps for some reason which kept causing the camera to lag.

This doesn’t happen on older versions of unity though. Might be some optimization error.