Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Join us on Dec 8, 2022, between 7 am & 7 pm EST, in the DOTS Dev Blitz Day 2022 - Q&A forum, Discord, and Unity3D Subreddit to learn more about DOTS directly from the Unity Developers.
    Dismiss Notice
  3. Have a look at our Games Focus blog post series which will show what Unity is doing for all game developers – now, next year, and in the future.
    Dismiss Notice

Cinemachine following networked objects (jitter)

Discussion in 'Cinemachine' started by BigJZ, Dec 14, 2020.

  1. BigJZ

    BigJZ

    Joined:
    Dec 13, 2019
    Posts:
    10
    tldr: i fixed jitter with manual update, but now my rigs don't work.

    The story begins with networking. We had severe jitter issues on clients who switch to cameras that follow other networked objects and we blamed the network at first.
    After noticing that in fact these objects are moving perfectly fine in the Scene view and the problem can be reproduced locally, we started looking into physics and cameras and updates. Due to how our architecture is set up, our objects consist of numerous independent networked entities, which work together and move as if attached together. Each of these objects can have slightly different interpolation time during a frame between the received states. So if a camera is looking at one such component, others might seem like they are out of sync in relation to the object we are looking at. When detached from an object, it works just fine. Tests with simple unity cameras yielded same results.

    Results:
    We set a simple camera to update its position without lerp, hardlocking it to the transform of what we wanted to follow. No matter how many other network entities were attached together, they all moved perfectly together.

    So we put the same logic into a cinemachine extension and we now override the VCam position at the end of LateUpdate. Maybe I just don't understand how it works, but before doing this, I tried all kinds of settings in the cinmeachine components and nothing worked. It only works if I literally set follow and lookat targets to null.

    Current issue:
    As I understand, there is some internal update logic going on which updates the rigs with orbit transposers and all that, as we can only set some axis values etc. Is it possible to feed the rig data and update it for camera rotation without having a real lookat target transform. The documentation mentions that this is what extensions are for, but maybe I am doing something completely wrong here? :)

    Thank you.
     
  2. BigJZ

    BigJZ

    Joined:
    Dec 13, 2019
    Posts:
    10
    pepeg
     
  3. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    6,411
    I'm not entirely sure what you're asking. Could you show an image of the inspector for your vcam rig?

    An Orbital Transposer in the Body section of the vcam changes the camera's position without changing the camera's rotation. So the values you put in the axes there will only affect the camera's position, not the rotation. The Follow target is used as a reference for this.

    In the Aim section, you can set up logic to control the camera's rotation. If you have a LookAt target, then you can use a Composer, for instance, to aim the camera towards the target. You can also put DoNothing here, and control the aim manually, with an extension or with a script, depending on your needs.

    The procedural algorithms in Cinemachine will follow your targets smoothly, provided that your targets are moving smoothly. If you have uneven interpolation in some or all of your targets, this will emerge as jitter - either in the target being followed or in the other targets or in the background. There is nothing any camera logic can do to fix this - you have to move your targets smoothly, or live with some jitter somewhere. The scene view is not a good indicator of animation smoothness. It will often look smooth even if the animation is not, because the camera there doesn't track the moving object.
     
  4. BigJZ

    BigJZ

    Joined:
    Dec 13, 2019
    Posts:
    10
    Hi Greg!
    Thank you for the reply!
    Here is how I`m trying to use it now:
    https://postimg.cc/Yj7jgRDN
    https://postimg.cc/BXQ6760X

    What I found was that if the VCam has follow or/and look at set, the position override with custom follow target that I do at the end of my LateUpdate in the extension behaves differently. Could it be because of some kind of fighting for positioning?

    If I want to use just the Look target and not Follow, can I set the same kind of 'do nothing' setting in the body section?

    My case is a network view object that interpolates between its' network states and calculates its' lerptime from the input sequence data + fixed server logic delta in order to make it smooth (so that states are interpolated to in full and do not jump over).
    Thing is that if the object is alone, it all works perfectly fine. However, when the object consists of numerous network views, each of them may have a different lerp time and if the camera follows one of them, the the others jitter.
    However if the camera does not follow any single object, everything is again perfectly smooth.

    I realize this is sorta out of the scope of cinemachine since I built my test cases with just a regular camera too with locally interpolated objects and observed the same results.

    But then my question is how the hell do I make sure that my objects are moving smoothly if I cannot trust the game view or the scene view?
     
  5. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    6,411
    Without the LookAt and Follow targets, the FreeLook is doing nothing at all for you. It's just a waste of resources and complicated for nothing. I suggest replacing the FreeLook with an ordinary vcam, then you can put DoNothing in Aim and Body, and attach whatever logic you like to control the transform.

    The problem is that the various objects are not moving consistently with respect to each other. There is no camera logic that will make this look smooth if you're tracking them with the camera. If the camera is static, then they still jitter, but we don't notice it because of the way our brains work. You have to find some way to smooth out the movement. Maybe some kind of smoothing filter on the interpolation could help. You have to do this in the targets, not in the camera. It really is dependent on the reason for the unevenness. In your place, I would try to look for the root cause for the unevenness and fix it so that they animate consistently.
     
  6. BigJZ

    BigJZ

    Joined:
    Dec 13, 2019
    Posts:
    10
    Yes you are correct. That has been one of possible conclusions that we entertained. It seems that we have to solve this differently. Thank you kindly. :)
     
  7. joe89

    joe89

    Joined:
    Jun 3, 2013
    Posts:
    4
    Hi, did you manage to solve this problem? Have same issue...
     
  8. Elharter

    Elharter

    Joined:
    Sep 20, 2015
    Posts:
    58
    Me too,have the same issue