- Home /
Jittery Camera Movement With 2D Rigidbody Player
Hello! I have a player that moves left and right controlled by this line of code:
playerRb.velocity = new Vector2(movement * speed * Time.deltaTime, playerRb.velocity.y);
I then have a camera that is following my player with a smooth delay with this line of code:
Vector3 desiredPosition = playerPosition.transform.position + offset;
Vector3 smoothedPosition = Vector3.SmoothDamp(transform.position, desiredPosition, ref velocity, smoothSpeed * Time.smoothDeltaTime);
transform.position = smoothedPosition;
But for some reason I still get this jittery movement:
Other things have a really bad jittery movements too. And my camera movement code is in LateUpdate(). Thank you for your help!
Answer by Namey5 · Mar 22, 2020 at 06:34 AM
Have you tried enabling interpolation on your rigidbody component?
Hi! Sorry I didn't see your comment yesterday! Thank you so much! It's working great, I was researching on interpolation and I guess of all the things I was trying I didn't think to just put the player rigid body in interpolation mode for some reason! Thank you lots again!
Your answer
Follow this Question
Related Questions
How to use Physics2D.OverlapCircleNonAlloc for ground check and jump 0 Answers
Help Adding Local Force and Rotating in a For Loop 2 Answers
Using IgnoreLayerCollision and IgnoreCollision together 0 Answers
Creating a delay after being grounded so the player can still jump while falling. 2 Answers
Why Physics2D.OverlapArea do not interact with tilemap? 1 Answer