Camera have weird jittering

Hello.

I’m using Cinemachine and the new InputSystem to make a first person camera. I’ve completed that task, but when I’m executing the game, when I move the player and the camera at the same time, it has some nasty jittering, and I don’t know exactly why. Here’s my code:

public class PlayerMovement : MonoBehaviour
{
    [SerializeField]
    private float moveSpeed;
    
    private Vector3 movement;

    private Rigidbody rb;

    private Transform cameraOrientation;

    private void Awake()
    {        
        rb = GetComponent<Rigidbody>();
        cameraOrientation = Camera.main.transform;
    }

    private void FixedUpdate()
    {
        //I'm using another class to get the values from the input
        Vector2 move = InputManager.Instance.GetPlayerMovement();        
        movement = new Vector3(move.x, 0, move.y);
        movement = cameraOrientation.forward * movement.z + cameraOrientation.right * movement.x;
        movement.y = 0f;
        rb.velocity = movement * moveSpeed;
    }
}

Thanks in advanced

If you use rigidbody, you should enable interpolation on it. If it still kinda jittery you should enable slight damping on cinemachine virtual camera to smooth it out.

It’s never a good idea to use damping for this purpose. It’s always best to figure out the source of the jittering and fix it properly. 90% of the time it has something to do with aliasing between FixedUpdate and Update, or you are moving the Rigidbody in such a way as to break interpolation.

1 Like