Unity: 2019.4.1f1 LTS
Cinemachine: 2.6.0
I have attached a small project with 2 scenes.
- “LateUpdateJitter” scene moves the character in LateUpdate using simple “Speed * Time.deltaTime”
- “RigidbodyJitter” scene sets velocity on a rigidbody attached to the character. Fixed Timestep is set to 30 frames a second. Rigidbody has interpolation set so it updates properly on LateUpdate.
There are two CinemachineVirtual Cameras and the issue is clear in both.
The first camera uses Y Damping, and has a 30 degree rotation on x-axis.
The second camera uses Z Damping and has no rotation. This jitter issue only occurs with use of Damping.
You can increase the damping and it will still happen, just make sure that the target is within the soft zone.
Change priority of cameras to test both out.
The issue is more pronounced in the Editor for me but still clearly visible in a build.
I have measured Time.deltaTime on my computer and it is not constant for some reason which could be the reason cinemachine acts this way. But I can’t expect users playing my game to have a perfect constant framerate either so it has to work in all situations.
Any suggestions?
Edit:
I found the post: Rigidbody jitter / lag when applying damping on Transposer and would say it is about the same issue.
I tried the CINEMACHINE_EXPERIMENTAL_DAMPING in Scipting Define Symbols but that made no difference sadly.
6042491–653054–CinemachineJitter.rar (30.1 KB)
DeltaTime fluctuation has been an issue in Unity for some time. You can read all the gory details here: Time.deltaTime Not Constant: VSync CameraFollow and Jitter
The good news is that this is being fixed, and DeltaTime will be much more steady in the near future (it’s a non-trivial fix, but it is happening).
The bad news is that camera damping is one of those things that’s very sensitive to a fluctuating deltaTime. Most of the jitter is specific to the Unity Editor, and is substantially reduced in the build (it is in your project). Often, this reduction (though not perfect) is good enough. If it isn’t, then the only workaround for the time being is to turn off damping, or use RigidBodies without interpolation and set the CM Brain to FixedUpdate. Then the cameras are rock-steady.
Update: just tried your project with 2020.2.0a16 - some jitter in editor, but cameras in build are absolutely stable, for both scenes. I think it’s safe to say that this problem is licked.
See here: Time.deltaTime Not Constant: VSync CameraFollow and Jitter page-8#post-5756152
Yes I have seen that thread. Unfortunately it seems OpenGL/Vulkan won’t be covered until 2021, and if that means 2021 LTS for a stable version of Unity with this fix then we are talking early 2022. So for the future, that’s great. For now I will have to create some temporary solution. I will try calculating the damping in FixedUpdate, and interpolating it in LateUpdate similar to how Rigidbodies move. Will see how that works out.