Object jitters when moving around it

As the title says, when I’m moving around the object I’m looking at, it jitters hard. However when I’m moving forward or strafe left, right, it looks normal.
Edited: I edited the code so that all input logic is in Update and physics logic in FixedUpdate. Problem still remains.

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

public class PlayerMovement : MonoBehaviour
{
    [SerializeField] Rigidbody playerRigidbody;
    [SerializeField] Transform playerTransform;
    [SerializeField] Transform cameraTransform;

    // Camera control variables
    [SerializeField] float mouseSensitivity = 100f;
    
    float xRotation = 0f; // xRotation is the rotation around x Axis, which is camera looking up down
    float mouseX;
    float mouseY;

    // Movement control variables
    [SerializeField] float movementSpeed = 12f;
    Vector3 moveDirection;
    float groundDragValue = 7f;
    float movementSpeedMultiplier = 10f;
    float forwardMovement;
    float sideMovement;

    // Jump control variable
    [SerializeField] float jumpSpeed = 12f;
    [SerializeField] Transform groundCheckSphere;
    [SerializeField] LayerMask groundMask;
    bool jumpInput;
    bool isGrounded;
    float airDragValue = 2f;
    float airMovementSpeed = 5f;

    // Crouch control variables
    bool crouchInput;

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

    // Update is called once per frame
    void Update()
    {
        MyInput();
    }

    // FixedUpdate has the frequency of Physic system and moving with ridigbody is based on Physic. So call MovementControl in
    // FixedUpdate makes movement smoother.
    private void FixedUpdate()
    {
        isGrounded = Physics.CheckSphere(groundCheckSphere.position, 0.4f, groundMask);
        Debug.Log(isGrounded);
        MovementControl();
        JumpControl();
        CameraControl();   
        DragControl();
        CrouchControl();
    }

    void MyInput() {
         // Get mouse input and apply mouse sensitivity
        mouseX = Input.GetAxisRaw("Mouse X") * mouseSensitivity * Time.smoothDeltaTime;
        mouseY = Input.GetAxisRaw("Mouse Y") * mouseSensitivity * Time.smoothDeltaTime;

        // Get movement
        forwardMovement = Input.GetAxisRaw("Vertical");
        sideMovement = Input.GetAxisRaw("Horizontal");

        // Get jump input
        jumpInput = Input.GetKey(KeyCode.Space);

        // Get crouch input
        crouchInput = Input.GetKey(KeyCode.LeftControl);
    }

    void CameraControl()
    {
        // Look horizontal
        playerTransform.Rotate(0f, mouseX, 0f, Space.Self);

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

        cameraTransform.localRotation = Quaternion.Euler(xRotation, 0f, 0f);

    }

    void MovementControl()
    {
        moveDirection = transform.forward * forwardMovement + transform.right * sideMovement;

        // Use normalized to make all the magnitudes to [-1, 1]
        if (isGrounded)
        {
            playerRigidbody.AddForce(moveDirection.normalized * movementSpeed * movementSpeedMultiplier, ForceMode.Acceleration);
        } else
        {
            playerRigidbody.AddForce(moveDirection.normalized * airMovementSpeed * movementSpeedMultiplier, ForceMode.Acceleration);
        }

    }

    void DragControl()
    {
        if (isGrounded)
        {
            playerRigidbody.drag = groundDragValue;
        } else
        {
            playerRigidbody.drag = airDragValue;
        }
    }

    void CrouchControl()
    {
        if (crouchInput)
        {
            playerTransform.localScale = new Vector3(playerTransform.localScale.x, 1.3f, playerTransform.localScale.z);
        } else
        {
            playerTransform.localScale = new Vector3(playerTransform.localScale.x, 2f, playerTransform.localScale.z);
        }
    }

    void JumpControl()
    {
        if (jumpInput && isGrounded)
        {
            playerRigidbody.AddForce(transform.up * jumpSpeed, ForceMode.Impulse);
        }

        if (playerRigidbody.velocity.y < 0)
        {
            playerRigidbody.AddForce(Physics.gravity * 4, ForceMode.Acceleration);
        }
    }
}

Here’s the video to show

The problem isn’t to do with the object but it’s todo with your camera. All you need todo is is replace Time.DeltaTime with Time.smoothDeltaTime

Hopefully this works :D.

It’s because you’re rotating a camera transform in FixedUpdate with zero relation to delta time between calls. This leads to inconsistent rotation as rendering frequency (framerate) is decoupled from physics updates.
_
It turned out that at least few factors contributed to this camera jitter behaviour. One, probably major one, was RB Interpolation setting while Camera being parented to that RB.

using UnityEngine;
public class PlayerMovement : MonoBehaviour
{
    [SerializeField] Rigidbody playerRigidbody;
    [SerializeField] Transform playerTransform;
    [SerializeField] Transform cameraTransform;

    // Camera control variables
    [SerializeField] float mouseSensitivity = 100f;
    
    float _xRotation = 0f; // xRotation is the rotation around x Axis, which is camera looking up down
    float _mouseX, _mouseY;

    // Movement control variables
    [SerializeField] float movementSpeed = 12f;
    float groundDragValue = 7f;
    float movementSpeedMultiplier = 10f;
    float _forwardMovement, _sideMovement;

    // Jump control variable
    [SerializeField] float jumpSpeed = 12f;
    [SerializeField] Transform groundCheckSphere;
    [SerializeField] LayerMask groundMask = 1<<0;
    bool _jumpInput, _isGrounded;
    float _airDragValue = 2f;
    float _airMovementSpeed = 5f;

    // Crouch control variables
    bool _crouchInput;
    [SerializeField][Min(0.001f)] float _mouseInputInterpolationTime = 0.1f;

    void Start ()
    {
        Cursor.lockState = CursorLockMode.Locked;
        playerRigidbody.freezeRotation = true;
    }

    void Update ()
    {
        float deltaTime = Time.deltaTime;

        // read player inputs:
        _mouseX = Mathf.Lerp( _mouseX , Input.GetAxis("Mouse X") * mouseSensitivity , deltaTime*(1f/_mouseInputInterpolationTime) );
        _mouseY = Mathf.Lerp( _mouseY , Input.GetAxis("Mouse Y") * mouseSensitivity , deltaTime*(1f/_mouseInputInterpolationTime) );
        _forwardMovement = Input.GetAxisRaw("Vertical");
        _sideMovement = Input.GetAxisRaw("Horizontal");
        _jumpInput = Input.GetKey(KeyCode.Space);
        _crouchInput = Input.GetKey(KeyCode.LeftControl);
    }

    void FixedUpdate ()
    {
        float deltaTime = Time.fixedDeltaTime;

        _isGrounded = Physics.CheckSphere( groundCheckSphere.position , 0.4f , groundMask );
        
        // MovementControl();
        var moveDirection = Vector3.Normalize( transform.forward*_forwardMovement + transform.right*_sideMovement );
        var moveSpeed = _isGrounded ? movementSpeed : _airMovementSpeed;
        playerRigidbody.AddForce( moveDirection * moveSpeed * movementSpeedMultiplier , ForceMode.Acceleration );
        
        // JumpControl();
        if( playerRigidbody.velocity.y<0 ) playerRigidbody.AddForce( Physics.gravity * 4 , ForceMode.Acceleration );
        else if( _jumpInput && _isGrounded ) playerRigidbody.AddForce( Vector3.up * jumpSpeed , ForceMode.Impulse );

        // DragControl();
        playerRigidbody.drag = _isGrounded ? groundDragValue : _airDragValue;
        
        // CrouchControl();
        float crouchScale = _crouchInput ? 1.3f : 2f;
        playerTransform.localScale = new Vector3( playerTransform.localScale.x , crouchScale , playerTransform.localScale.z );

        // CameraControl();
        // mouse look, horizontal
        playerTransform.Rotate( 0 , _mouseX*deltaTime , 0 );
        // mouse look, vertical
        _xRotation = Mathf.Clamp( _xRotation - _mouseY*deltaTime , -90f , 90f );
        cameraTransform.localRotation = Quaternion.Euler( _xRotation , 0f , 0f );
    }

}

The ground is not jittering though right? This is very strange
The object has no custom behaviour, it’s just a box?

So as andrew-lukasisk (sorry I cannot tag you some how) explained above, I tried to move the multiplication withTime.smoothDeltaTime into the CameraControl method. Therefore it will be called in FixedUpdate to match the camera movement with the physics update. However it does not solve the problem at first.

BUT I tried increasing the frequency of FixedUpdate call by changing the Fixed Timestep from 0.02 to about 0.0025. And it reduces the jittering (but still can be noticable). And changing it to 0.001, the jittering reduces to the point I think acceptable. But if one put attention on it, the jittering can still be notice.

I’m fairly new with this technical thingy, therefore I don’t know what is the downside of the small Fixed Timestep. So if there is other solution, please share.