Search Unity

Discussion [(semi-)SOLVED] Cinemachine Freelook Has Bad Jitter at High Speed [Reinstall Cinemachine can help]

Discussion in 'Cinemachine' started by Kinnith7, Jan 7, 2021.

  1. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,711
    My suggestions were to address the head bobbing. If head bobbing isn't the problem, then please ignore those suggestions.

    I didn't expect it to change anything. I need to know what is says in the FreeLook inspector, where I indicated, when it is running in smart update. That information will help me diagnose the problem.
     
    tatoforever likes this.
  2. tatoforever

    tatoforever

    Joined:
    Apr 16, 2009
    Posts:
    4,368
    The bobbling is a wanted effect (noise) that I added. Although the jitter is visible with and without the noise effect.

    Sorry I missunderstood your request, it says Late Update:
    upload_2022-9-7_16-30-0.png

    Side note, with SmartUpdate the jitter happens at high frames (like 120+). If I force a Vsync or lower the FPS to less than monitor refresh hz the jitter is gone. I'm building now for Nintendo Switch to see if the jitter is noticeable with this setup.
     
  3. tatoforever

    tatoforever

    Joined:
    Apr 16, 2009
    Posts:
    4,368
  4. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,711
    ok, thanks.

    Can you do another diagnostic test? What happens if you set all the CM damping to 0? You'll have to do it in the 3 FreeLook rigs, both Body and Aim - that's something like 15 damping settings. Does the jitter stop when all damping is 0? This is just a diagnostic, I'm not suggesting that you should leave the damping at 0.
     
  5. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,711
    ok, I can see some jitter now. Just to confirm that we're talking about the same thing: the background moves smoothly, but the character itself jitters a little in the frame. Is that right?

    That kind of jitter is often symptomatic of the character not being moved smoothly. For example, if some motion is happening on FixedUpdate, and other motion is happening on Update. Can you say something about how you are moving the character? Is FixedUpdate involved?
     
  6. tatoforever

    tatoforever

    Joined:
    Apr 16, 2009
    Posts:
    4,368
    Jitter is 100% gone with all damping set to 0:
    upload_2022-9-7_16-47-49.png
     
  7. tatoforever

    tatoforever

    Joined:
    Apr 16, 2009
    Posts:
    4,368
    Yes, everything is smooth except the target, but now with the damping set to zero no more jitter however i need a bit of damping. lol
    My character Animator moves and its properties values are updated in Update callback.
     
  8. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,711
    That symptom also supports my hypothesis of a non-smoothly animated character. What can you tell me about your character controller?
     
  9. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,711
    What about the character's transform? How is it moved?
     
  10. tatoforever

    tatoforever

    Joined:
    Apr 16, 2009
    Posts:
    4,368
  11. tatoforever

    tatoforever

    Joined:
    Apr 16, 2009
    Posts:
    4,368
    The character is moved in the OnAnimatorMove with this simple rootmotion code:
    Code (CSharp):
    1. navMeshAgent.velocity = animator.velocity;
    2.          
    3.             var positionY = Mathf.Lerp(transform.position.y, navMeshAgent.nextPosition.y, Time.deltaTime * 6f);
    4.             transform.position = navMeshAgent.enabled ? new Vector3(navMeshAgent.nextPosition.x, positionY,  navMeshAgent.nextPosition.z) : animator.rootPosition;
    5.             transform.rotation = animator.rootRotation;
    So in conclusion, without damping no jitter and theres also no jitter with my camera controller. So i suspect is somewhere in the damping/interpolation of Vcams?
     
  12. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,711
    I'm not too familiar with the workings of navMeshes so can't really comment on the motion code. My gut still says to look for unsmoothness there. These symptoms:
    • Camera damping > 0: character jitters, background smooth
    • Camera damping == 0: character smooth, background jitters
    • jitter is dependent on framerate
    point almost 100% to a character that is not smoothly animated. There is nothing that the camera can do to correct that. You have to fix the animation, or forget about damping.
     
  13. tatoforever

    tatoforever

    Joined:
    Apr 16, 2009
    Posts:
    4,368
    I don't think is the animation, it only happens with cinemachine and in some circumstances.
    I just did a nintendo switch build, there's no jitter and damping is enabled on my vcam:

    I get the jitter in editor but only when there's damping or with with high FPS (like more than 120). With my camera controller I don't get any jitter no matter what FPS and it has more damping than my vcam setup.
    So what's going on here? :)
     
  14. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,711
    So wait a minute - the jitter is only in the editor?
    Is there an inspector visible? Try it with no object selected and therefore no inspector. Does the jitter change?
    What version of Unity are you using? And what version of CM?
     
  15. tatoforever

    tatoforever

    Joined:
    Apr 16, 2009
    Posts:
    4,368
    No inspector is visible. Again only happens if the FPS is high or damping is enabled. In the editor if I lower the FPS the jitter is gone. Has something to do with deltaTime computation?
    Im on 2019.4.40f1 and CM 2.9.1
     
  16. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,711
    It might have something to do with deltaTime computation. In 2020.2, Unity's deltaTime code was significantly improved. You might want to consider upgrading to 2020.

    If the problem is only in editor, then I'm not going to worry about it. Let me know if it shows up in the build.
     
    tatoforever likes this.
  17. tatoforever

    tatoforever

    Joined:
    Apr 16, 2009
    Posts:
    4,368
    I'll do a PC build and report back later on.
     
  18. tatoforever

    tatoforever

    Joined:
    Apr 16, 2009
    Posts:
    4,368
    We can't upgrade to 2020/2021, it has performance drawbacks for our game, we are saddly locked to 2019.
    However when I tried in 2020/2021 not long ago, my camera controller exibit the same issue cinemachine vcams has with characters jittering and damping in 2019. It might have something to do with deltaTime. However i don't have that issue with my camera controller damping in 2019.
    As of now, Nintendo Switch builds with cinemachine are fine, don't know other platforms (PS4/XONE), need to build to those. If the problem persist on those platforms, I might have to let go the posiblity of using cinemachine which will be really sad, it has nice features. :(
     
    Last edited: Sep 8, 2022
  19. tatoforever

    tatoforever

    Joined:
    Apr 16, 2009
    Posts:
    4,368
    I got another issue with cinemachine, after mounting a small cut-scene for testing (with timeline) I got a huge spike from hell when transitioning from the cut vcam to the gameplay vcam (the FreeLook camera we where discussing earlier):

    Deep profile:
    upload_2022-9-7_23-53-53.png

    I think i will both ditch timeline and cinemachine all together. Maybe in the future I will give it another try.
     
    AcidArrow likes this.
  20. ManieBesselaar

    ManieBesselaar

    Joined:
    Nov 1, 2018
    Posts:
    30
    Hi everyone.
    Thought I'd share how I solved this on my end. Checked the cinemachine settings , tried just a fixed cockpit camera (no cinemachine) , checked framerates and used the profiler to check my game loop. No luck. Noticed that my space ship has tremendous acceleration compared to the one in the tutorial I was following ( I may not have gotten every detail right, I like to learn while breaking stuff).
    Tuned the thrust down and realised that it was taking longer for the shake to start, After some more experimentation I realised that I traveled very far on each test run.
    I realised that the numbers for my position vector were getting very large ( 8000 + per axis). So I exited play mode. Set my initial position to a large number as described above, and the camera shake started instantly when my ship moved.
    My guess is that as the vector3 numbers for the position of the gameobject or rigidbody gets too big, the precision of the physics calculations start to suffer.
    Would like to know if any one else can duplicate this and if I am on the right track. Feel free to correct me on the technical details.
    Either way , my problem was solved by just letting my space ship move at a lower speed and keeping my objectives within a certain area.
    Hope this helps someone.

    Editing this post with new information. A friend sent me this link explaining the issue http://davenewson.com/posts/2013/unity-coordinates-and-scales.html
     
    Last edited: Sep 8, 2022
    tatoforever likes this.
  21. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,711
    That spike looks disturbing indeed. I don't like those GC allocs, either. Thanks for bringing this up, we'll have a look at what might be causing this.
     
    tatoforever likes this.
  22. tatoforever

    tatoforever

    Joined:
    Apr 16, 2009
    Posts:
    4,368
    Any news about this?
     
  23. tatoforever

    tatoforever

    Joined:
    Apr 16, 2009
    Posts:
    4,368
    @Gregoryl
    You guys found something about the blending cameras huge spike?
     
  24. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,711
    Not yet. It's on our list so we won't forget about it.
     
    tatoforever likes this.
  25. tatoforever

    tatoforever

    Joined:
    Apr 16, 2009
    Posts:
    4,368
    @Gregoryl
    The spike still present on cinemachine v2.9.2 with timeline v1.8.0:

    Deep profile:
    upload_2022-11-17_15-55-36.png
    Also cinemachine inspector is destroyed in this version:
    upload_2022-11-17_15-30-7.png
     
    Last edited: Nov 17, 2022
  26. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,711
    I have tried but have been unable to repro this. Can you show me the scripting defines in your Player Settings?
     
  27. tatoforever

    tatoforever

    Joined:
    Apr 16, 2009
    Posts:
    4,368
    Two defines, one for Post process stack 2 and the suggested cinemachine experimental damping to avoid jittery:
    upload_2022-11-18_18-22-29.png
     
    Last edited: Nov 19, 2022
  28. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,711
    aha! Remove the Cinemachine experimental damping define, and the spike will disappear.
    We can look at alternatives for improving the jitteriness, if it's still there.
     
    tatoforever likes this.
  29. tatoforever

    tatoforever

    Joined:
    Apr 16, 2009
    Posts:
    4,368
    Yeah I just tried that and removing the CINEMACHINE_EXPERIMENTAL_DAMPING fixes the spike of death. The jittery is only visible in editor not at runtime (not a big deal).
     
    Gregoryl likes this.
  30. tatoforever

    tatoforever

    Joined:
    Apr 16, 2009
    Posts:
    4,368
    Would like to mention that the stutter/jitter issues we had in Editor with Cinemachine is also gone in v 2.9.3 and 2.9.4. Also, the inspector that was broken got fixed too.
    Good job on fixing those issues so fast!
     
    Gregoryl likes this.
  31. xorblax

    xorblax

    Joined:
    Jul 15, 2018
    Posts:
    25
    Just wanted to add that I'm having the same issue in Unity 2021.3.15 where there is stuttering with the damping in editor but not in build. I'm currently trying to install the latest update of cinemachine, but the package manager is just showing that I have the latest version, when I don't, I only have 2.8.9.
    I tried editing the manifest.json file to force it, where it tells me it's not built for the version I'm using, even though the changelog for cinemachine states that 2.9.4 is for versions 2019.4 and up?
    Also it didn't fix the stuttering. I'm fine with waiting for the update, I just figured I'd mention the changelog thing.
     
    Last edited: Dec 3, 2022
  32. tatoforever

    tatoforever

    Joined:
    Apr 16, 2009
    Posts:
    4,368
    Make sure you don't have the script define CINEMACHINE_EXPERIMENTAL_DAMPING (check in Player Settings). This was the real cause of stuttering and the spike of hell I was having.
     
  33. xorblax

    xorblax

    Joined:
    Jul 15, 2018
    Posts:
    25
    It wasn't ever enabled for me:
    upload_2022-12-6_11-37-19.png
    The jitter is gone in build, it's just in editor where it appears. I'm not sure when update 2.9 for cinemachine is coming to my version of unity, but I'm fine with waiting until that comes and fixes it.
     
  34. tatoforever

    tatoforever

    Joined:
    Apr 16, 2009
    Posts:
    4,368
    You gotta click "show all versions", is there (im on 2019.4)
     
  35. tatoforever

    tatoforever

    Joined:
    Apr 16, 2009
    Posts:
    4,368
    In version 2.9.2 (or .3) the Editor jitter was completly gone. Make sure you upgrade to the latest version of Cinemachine. Is working fine for me since.
     
    Lars-Steenhoff likes this.
  36. xorblax

    xorblax

    Joined:
    Jul 15, 2018
    Posts:
    25
    The "show all versions" toggle isn't available for me, it was apparently removed from version 2021. I did try editing the manifest file to force download version 2.9.2, but that didn't fix the jitter. Anyway this latest version is quite recent, and I'm comfortable waiting for its release on my version, as fixing the jitter isn't a pressing issue at the moment. Thanks though.
     
  37. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,711
    Try 2.9.4.

    It should be stated that there are many possible causes for jitter, and it could be that the issue in this thread is not related to your jitter. If you'd like to start another thread in which you show the jitter you're getting, we can try to solve it.
     
  38. xorblax

    xorblax

    Joined:
    Jul 15, 2018
    Posts:
    25
    See I can't get any version of 2.9. The package manager only gives me the option for Cinemachine 2.8.9, even if I make a new empty project. I'm using Unity version 2021.3.15f1.
    upload_2022-12-13_10-12-29.png
     

    Attached Files:

  39. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,711
    Yes, for some reason Unity 2021 is hiding compatible packages from the menus, I don't know why. Hopefully this will change in future releases.

    For now, you can add packages by name/version this way:

    upload_2022-12-13_11-16-45.png
     
    xorblax likes this.
  40. xorblax

    xorblax

    Joined:
    Jul 15, 2018
    Posts:
    25
    Thank you, that worked. If I still find judder then I'll make that thread like you mentioned.
     
  41. abhinavpv

    abhinavpv

    Joined:
    Apr 14, 2022
    Posts:
    7
    i am having similar problem of cinemachine jittering at high speed(when sprinting). In my case jittering only occurs in android build. in pc no jittering occurs. And jittering occurs when frame rate is less than 30fps in android. when getting solid 30 fps no jittering occurs. And also jittering only occurs when moving in forward direction. when moving backward or sideward no jittering occurs. i posted a video showing this problem

     
  42. abhinavpv

    abhinavpv

    Joined:
    Apr 14, 2022
    Posts:
    7

    This happens also when the player is moving at high speed 100 meters a second
     
  43. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,711
    Do you have a CinemachineCollider on the vcam? Can you show the vcam inspector? What version of CM? (this really should be a new thread, it has nothing to do with what came before)
     
  44. abhinavpv

    abhinavpv

    Joined:
    Apr 14, 2022
    Posts:
    7
    I am having similar problem help me
     
  45. abhinavpv

    abhinavpv

    Joined:
    Apr 14, 2022
    Posts:
    7
    Turning off the cinemachine collider solved the problem. But i need cinemachine collider
     
  46. abhinavpv

    abhinavpv

    Joined:
    Apr 14, 2022
    Posts:
    7
    Removing the default from the collider layer solved it
     
    Gregoryl likes this.
  47. Kinnith7

    Kinnith7

    Joined:
    Jul 4, 2017
    Posts:
    84
    @abhinavpv Thanks for this info! May come in handy for me also soon!
     
  48. yonatanab1

    yonatanab1

    Joined:
    Sep 9, 2018
    Posts:
    56
    hello, I am facing the same issue.
    Have you been able to solve this?
    Thanks
     
  49. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,711
    There are many possible causes for jitter. Can you start a new thread and give details of your setup and the effect you're seeing?
     
  50. Kinnith7

    Kinnith7

    Joined:
    Jul 4, 2017
    Posts:
    84
    @yonatanab1 It's been over 2 years since I worked on this so my memory is fuzzy on it. I can see from the posts I made here that uninstalling and reinstalling Cinemachine helped me some. Maybe that is something to start with. See what happens. Sorry, I can't be of more help at this time.
    I am getting ready to get back into that project for a game I am developing. I may hit the problem again. So if you come up with a better fix if you can post it here I would greatly appreciate it. I am sure others would also. I still get hits on this thread from people looking for a solution.