Camera freezes when interpolation mode is enabled in RigidBody

I have a problem: when I add a Rigidbody to the player and turn on interpolation, then when I rotate the camera with the mouse, it starts to stutter. I am using the following code to enable a radio button:

[SerializeField]
    public float MouseSpeed = 200f;

    public Transform playerBody;


    float xRotation = 0f;

    // Use this for initialization
    void Start()
    {
        Cursor.lockState = CursorLockMode.Locked;
    }
    private void LateUpdate()
    {
        float mouseX = Input.GetAxis("Mouse X") * MouseSpeed * Time.deltaTime;
        float mouseY = Input.GetAxis("Mouse Y") * MouseSpeed * Time.deltaTime;



        xRotation -= mouseY;

        xRotation = Mathf.Clamp(xRotation, -90f, 90f);
        transform.localRotation = Quaternion.Euler(xRotation, 0f, 0f);


        playerBody.Rotate(Vector3.up * mouseX);

    }

Why might this be happening?

This happens because both the rigidbody and your script are fighting for control over the transform’s rotation.

Interpolation works by taking the rigidbody’s position in the previous frame and its current position, and picking an intermediate value between them based on the amount of time passed. Then the result is written to the transform’s position, so the transform will sit in between two different physics states. Same thing applies to rotation.

So if you want to rotate a rigidbody, rotate the rigidbody, not the transform. Keep in mind that transform.position and rigidbody.position are not the same thing, and will often have different values when interpolation is enabled.

Thank you, I’ve been looking for an answer for so long, but it turned out to be so simple…