I know this is a very common question. However, none of the common solutions are effective. I’ve stripped out every fancy feature to the bare basics supporting my desired camera style, and still encounter the problem. Despite many attempts to correct the behavior, the camera always “jerks” into position every frame. Summary follows:
Some code for the curious:
Pastebin link
A video for the curious: Youtube link
(Reflects the method outlined here almost completely, and with identical results.)
Setting the camera position explicitly to its desired position eliminates the mystery jitter, but produces the jitter characteristic of setting your camera to follow a rigidbody without a smoothing behavior. Using a very high Lerp value to move the camera into position eliminates most jitter, but does not produce the desired 'laziness."
Ship is a rigidbody with (freezeRotation = true);
Ship rigidbody set to “Interpolate”
Camera seeks a position behind & above the ship.
Camera LooksAt a point ahead of & above the ship.
Every Update:
I take mouse/keyboard input
From input, I get the desired rotation for my rigidbody ship.
Bypassing its rigidbody, I Lerp the ship’s transform.rotation towards its rotation goal.
…(also tried doing that in FixedUpdate, exacerbating the jitter)
…(also tried adding to rotation instead of Lerping to a goal, exacerbating the jitter)
From the ship’s current position/rotation, I get the desired position of my camera.
…(which is always a point behind and above the ship regardless of the ship’s orientation)
Every FixedUpdate:
I apply force to the ship’s rigidbody with AddForce(transform.forward * thrust)
Every LateUpdate:
I Lerp the camera towards it’s desired position, and have it LookAt its target.
…(also tried doing this in FixedUpdate and Update, which still cause jitter)
Any clues for me? A swift kick in the right direction would save me another afternoon of headaches.