Search Unity

Jittering

Discussion in 'Cinemachine' started by corjn, Dec 26, 2017.

  1. corjn

    corjn

    Joined:
    Feb 6, 2014
    Posts:
    168
    Hi, I just updated to Unity 2017.3.0f3 and it's jittering a lot when you turn the camera in free look horizontal in Late Update. That was not the case before with 2017.2.0f3. Tried on a debug project with only cinemachine, same problem.
    (Not in fixed update, but, the fixed update is actually dependent to the time scale. If the fixed time step is 0.2 on a 140 fps screen, it will jitter as the physics will actually render at something like 60 fps. So that's not an option for me.)

    I'm using cinemachine 2.1.10

    Thanks in advance for your precious time,

    Jonathan
     
    Last edited: Dec 27, 2017
  2. JakubSmaga

    JakubSmaga

    Joined:
    Aug 5, 2015
    Posts:
    417
  3. corjn

    corjn

    Joined:
    Feb 6, 2014
    Posts:
    168
    Hi, @JacobSmaga, thanks for the quick feedback. I'm making this right away !
     
    Last edited: Dec 27, 2017
    JakubSmaga likes this.
  4. corjn

    corjn

    Joined:
    Feb 6, 2014
    Posts:
    168
    Well, my bad, after some more testing I realized the jittering was always here (I have two laptops, a portable and a tower, jitter can be seen better with the tower and big screen). So not a unity 2017.3 problem.

    Still, i'm really having a hard time figuring out how not having jitter at all with a physic object as a target. Like I said in the first post, the fixed update does not really fix it. Sure it's more stable, but you'll still have some jitter, especially on a 140 fps display. (and solving that by putting fixed time step at 0.1 is not a solution, with a lot of physics objects the cpu will just have to much work)

    I'm going to make a full debug repro project and video captures to see how we can solve this jitter issue.

    Edit : this might solve it : https://docs.unity3d.com/ScriptReference/RigidbodyInterpolation.html

    Edit 2 : Solved it ! So for everyone having the issue and want a really smooth camera with a physic target :

    -Put your cinemachine Brain in Late Update

    -Make your physic target rigidbody in interpolate or extrapolate (see the differences in the api with the link above)



    -If you want an independant target object follwing the physic thing you want to track (nice for more personnal settings by script), just make an empty game object, add a kinematic rigidbody component to it. Set the same interpolation as your physic object. And then by script use "Rigidbody.MovePosition"

    "Use Rigidbody.MovePosition to move a Rigidbody, complying with the Rigidbody's interpolation setting." (source : https://docs.unity3d.com/ScriptReference/Rigidbody.MovePosition.html)
     
    Last edited: Dec 27, 2017
  5. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,711
    @corjn Can you check whether you get the same result with interpolate/extrapolate and the CinemachineBrain in Smart Update instead of Late Update? My theory is that it will work just as well, since the Smart Update algorithm is designed to handle exactly this situation. If it doesn't work properly I'd like to know about it so we can address the issue.
    Thanks
     
  6. corjn

    corjn

    Joined:
    Feb 6, 2014
    Posts:
    168
    Hi, @Gregoryl, I did not knew that smart update was making that, I thought it was just something that would automatically put the brain in fixed update if the target is physic. So that's good to know ! I'm going to make some more tests then and publish results here.
     
  7. HelloGoodSir

    HelloGoodSir

    Joined:
    Oct 17, 2017
    Posts:
    1
    I ran into this issue with my side scrolling endless runner I am making. I ended up getting the best results with the camera set to Smart Update, my Fixed Timestep set to 0.0166667 & Target Framerate set to 60. I played around with setting my Rigidbody to Interpolate but in the end I use it only while in a slow motion sequence in my tutorial. I call my AddForce() in FixedUpdate(). It has been a rather big challenge to get this nailed down.