Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Bug Cinemachine camera jitters while following moving object.

Discussion in 'Cinemachine' started by gurbrindersingh, Mar 16, 2022.

  1. gurbrindersingh

    gurbrindersingh

    Joined:
    Feb 28, 2017
    Posts:
    32
    Steps to Reproduce:
    1. Create a cube gameobject in scene
    2. Attach a script on cube with following code in update
       transform.Translate(Vector3.forward * 50f* Time.deltaTime);
    3. Create a new virtual camera
    4. Assign cube into Follow and Look at fields of virtual camera and adjust track and aim offsets
    5. Observe the jitter

    Additional info:
    • Neither rigidbodies are added to project nor any other code is in use than the above line of code mentioned in step 2.
    • Using Unity 2020.3.14f1 with Cinemachine 2.6.11 package


    (Below giffy is recorded via Unity recorder with variable frame rate and it appears more laggy than otherwise it is)
    gif_animation_002.gif


    Sample project is attached herewith.
     

    Attached Files:

  2. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,658
    Thanks for the detailed report. I opened your project with 2020.3.30f1 and ran the scene. It's perfectly smooth for me.

    Note: be sure to run such tests without an object selected and a visible inspector. Inspector redraws and other editor overhead can affect framerate and smoothness. Ideally, you should never judge game smoothness in the editor. Make a build and run that.
     
  3. gurbrindersingh

    gurbrindersingh

    Joined:
    Feb 28, 2017
    Posts:
    32
    Thanks for the update, Gregoryl.

    For me it stutters little bit (but noticeable) even without an object selected and a visible inspector. On selecting virtual cam while it is following, rotation seems to be fluctuating on x axis if wee see the inspector. Is it normal behavior while following object or it may be adding that stutter? Does it behave same at your side where it runs smooth?

    upload_2022-3-17_9-7-48.png upload_2022-3-17_9-9-6.png


    I'll try once on real device though after a build.
     
  4. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,658
    Please let me now how that goes. For me it doesn't stutter at all.
     
  5. gurbrindersingh

    gurbrindersingh

    Joined:
    Feb 28, 2017
    Posts:
    32
    Hi,
    I tried apk on Android device. Although it appears much more smooth than the editor, it still jitters randomly while following the object.
    (Tested on Xiaomi MI A1 old test device)
     
  6. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,658
    Unity can have a fluctuating framerate, especially if there is other activity on the device that's using CPU. I suspect that the jitter you're seeing (a video would be helpful here) is a result of that, since Unity has no way of knowing in advance what the actual deltaTime will be for the current frame, and so uses prior frame data to estimate it. Damping on a camera tends to make this fluctuation more obvious. I bet that the jitter disappears entirely when the damping is set to 0.