Search Unity

Bug Cinemachine LateUpdate Jitter

Discussion in 'Cinemachine' started by KubiWay, Jul 1, 2020.

  1. KubiWay

    KubiWay

    Joined:
    Oct 7, 2014
    Posts:
    17
    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: https://forum.unity.com/threads/rig...ng-damping-on-transposer.535548/#post-3638500 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.
     

    Attached Files:

    Last edited: Jul 1, 2020
  2. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,730
    DeltaTime fluctuation has been an issue in Unity for some time. You can read all the gory details here: https://forum.unity.com/threads/time-deltatime-not-constant-vsync-camerafollow-and-jitter.430339/

    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.
     
  3. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,730
  4. KubiWay

    KubiWay

    Joined:
    Oct 7, 2014
    Posts:
    17
    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.