- Home /
Camera Lerp Jitter
I've been trying unsuccessfully to remove the jitter from the camera which is following a moving player. The player is moved by Vector3.MoveTowards. The camera Lerps to get a nice lag as if the player has outrun the camera.
The following code is in LateUpdate and is attached to the camera.
if (!player.rotating)
{
direction += -target.up * height;
newPos = target.position - (direction * distance);
}
transform.position = Vector3.Lerp(transform.position, newPos, Time.deltaTime * moveSpeed);
Quaternion wantedRotation = Quaternion.LookRotation(target.position - transform.position, target.up);
transform.rotation = Quaternion.Slerp(transform.rotation, wantedRotation, Time.deltaTime * rotationSpeed);
This code does work as intended but causes a very noticeable jitter. I have searched a lot over the last few weeks for a solution but none have worked.
I've tried:
Child camera to player - this works however there is no lag (which I want).
Child camera and adjust the localPosition to mimic lag. This instead looks as if the camera has moved backwards rather than slowed.
Lerp from/to a set start and end point - no noticeable difference.
Used SmoothDamp instead of Lerp - works only at slow speeds. The faster the camera moves, the more it begins to jitter.
Removed the RigidBody from the player/change interpolate settings - no difference.
Tried in Update, LateUpdate & FixedUpdate - no difference.
Have I missed something or is it normally this difficult to get a moving camera to following a moving object?
Any ideas would be welcomed.
It's starting to look like it isn't possible with Unity. I simply made the camera move forward and not follow anything and it still jerks. It seems a camera can only directly be moved, using Lerp simply doesn't work.
I've really run out of things to try now.
Your answer
![](https://koobas.hobune.stream/wayback/20220613145236im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Camera jitter when using Lerp/Slerp 1 Answer
Lerping orthographic camera size jitters 1 Answer
Physics + first person camera = jitter? 4 Answers
How you change another script value smoothly on trigger 0 Answers
lerping transform.position on a camera 0 Answers