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. Kinnith7

    Kinnith7

    Joined:
    Jul 4, 2017
    Posts:
    84
    I love Cinemachine, and want to use it exclusively, but I am having this odd problem. When my object moves at low speed (20 meters or less) along the Z axis everything is GREAT! But when I speed the ship up, as if to go into hyperdrive, like 100 meters a second, I get this odd "jumping" from behind the ship. See this short video for a full explanation and CM Freelook cam setup. Any help appreciated.
     
  2. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,724
    That's really strange. A few questions:
    1. Are you moving the ship using physics forces, or are you calculating the transform manually?
    2. What is the Update Mode of your CM Brain?
    3. Does the jitter happen if you turn all the damping in the 3 FreeLook rigs to 0?
    4. Does the jitter happen if you replace the FreeLook with a simple vcam with Transposer/Composer?
    5. Does the jitter happen if you replace the FreeLook with a simple vcam with FramingTransposer/POV?
     
  3. Kinnith7

    Kinnith7

    Joined:
    Jul 4, 2017
    Posts:
    84
    Hi, thanks for responding. I am not using physics, just a very basic .MOVE with Character controller. I have tried different Update modes in CM Brain. FixedUpdate jitters all the time, Late and Smart have the effect you see here. All damping to 0 yields the same result. If I replace it with a simple vcam it follows fine. For questions 4 and 5, I just tried those combinations and it followed fine with no jitter. For some reason, it's just the Freelook cam. I experimented all this morning with about every setting I could and couldn't find anything that even made the smallest amount of difference. I was thinking that maybe the Freelook cam just wasn't updating fast enough to stay caught up from behind but if that were true when I swing it around to the front of the ship shouldn't it be bouncing "into" and out of the ship really fast? This one has really got me perplexed. Thanks for looking at my problem.
     
  4. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,724
    That's really strange behaviour from the FreeLook, and I would like to investigate it further. Would you be willing to send me your project?

    I saw your tutorial video posted on the other thread. Nice job. I have one comment: if you're doing a spherical orbit, then FreeLook isn't the best choice of rig. Much simpler and more efficient is the FramingTransposer + POV combo. Modify your zoom script to affect only
    vcam.GetCinemachineComponent<CinemachineFramingTransposer>().m_CameraDistance
    . The whole thing is way easier to control and set up.
     
    Siddharth_2077 and gaborkb like this.
  5. Kinnith7

    Kinnith7

    Joined:
    Jul 4, 2017
    Posts:
    84
    Wow!, that combination (framing transposer + pov combo) works perfectly for what I was trying to do in the first place anyway! I just turned the damping down all the way and the camera works perfectly. I even turned the ship speed up to 1000 and the camera hung right with it with zero jitter. Now I just change my zoom script per your advice above and I should be back in business. I have no problem sending you my project if you still want to look at it, but it seems what you have just suggested is what I should have been doing in the first place. Many thanks!, Just let me know if you are still interested in the project, I will pack it and share. Just let me know.!.
     
  6. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,724
    Yes please, I would like to get to the bottom of the FreeLook issue. If you could send me a small repro project I would be most appreciative.
     
  7. Kinnith7

    Kinnith7

    Joined:
    Jul 4, 2017
    Posts:
    84
    Ok, my project was just a project where I was testing a bunch of stuff so it had gotten pretty big. So I made just a version for you with just the ship and movement and it worked perfectly with the freelook camera when I rebuilt it. (???) So I compared the freelook camera in both versions and the only difference was that in my broken version under "AXIS CONTROL" the fields for Input Axis Name under both the X and Y axis had vanished. It said this field controlled auto updating of those axis. So I guess whatever I did cut that off. But I don't know how I did it. Here is my project. I couldn't get the error to repeat. I hope it helps you. At least I know what not to do, I just wish I knew how I did it. Thanks for your help. Here is a link to my project. Let me know you have it downloaded so i can delete the folder please. https://drive.google.com/drive/folders/1wUuBRuMKNU5D4Fso2UtmISHJJo4jnpNb?usp=sharing
     
  8. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,724
    Seems that you have already deleted it :-/
    Thanks anyway :)
     
  9. Kinnith7

    Kinnith7

    Joined:
    Jul 4, 2017
    Posts:
    84
    It's there now! With this link. Sorry, I didn't hear any more for a few days and thought you had moved on. The ship is something I made in blender special for my game. Didn't want someone trying to get the model and selling it before my game came out. I put the zip file back. Just let me know you got it. Sorry for the confusion. You helped me, didn't want to leave you hanging. But didn't know if you were coming back. thanks. https://drive.google.com/drive/folders/1Nlp1ONCK-SH4u3Ql1nC1jPWBVcJMaPUM?usp=sharing
     
  10. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,724
    Got it, thanks. FYI in the future for privacy you can DM me with this sort of thing. Any special repro instructions? (e.g. what scene to open, what to do, what to look for)
     
  11. Kinnith7

    Kinnith7

    Joined:
    Jul 4, 2017
    Posts:
    84
    Excellent, thank you sir for your help. I will do that! I'm playing with the same file now trying to figure out what made those "Input Axis Value" fields disappear in CM Freelook1. I think that's what did in my original test project. Should be nothing special for the project, just have Input System and Cinemachine installed, otherwise it should be all set up. Anything else you need from me fell free to ask. -ken.
     
  12. Kinnith7

    Kinnith7

    Joined:
    Jul 4, 2017
    Posts:
    84
  13. ashdev18

    ashdev18

    Joined:
    Aug 2, 2020
    Posts:
    12
    is the issue solved? i am also having similar issue with virtual camera. at high speed it bounces a bit. i am using with vehicles. the vehicle has very high speed around 250 km/hr. at higher speed it bounces but not that high amount (its like glitching).

     
  14. Kinnith7

    Kinnith7

    Joined:
    Jul 4, 2017
    Posts:
    84
    Hello ashdev18, It's been almost 2 years since I posted this and I wish I had documented here better how I solved the problem. I can't remember right off how I did it and I am away on vacation right now. But, if you read through the thread it seems I followed the unity techs' suggestions and discovered the issue. I would suggest reading through this entire tread, maybe it will help you as well. When I get home later in the week I will see if I still have the project and see if I can remember what I did to correct it. Sorry I can't be of more help at the moment. This was done in Jan 21'.
     
  15. einWikinger

    einWikinger

    Joined:
    Jul 30, 2013
    Posts:
    97
    @ashdev18 We had similar issues with Freelook where the dampening was very sensitive to frame time fluctuations in combination with rigidbody interpolation and CM Brain Smart Update mode. I'd suggest looking into these (as previously suggested) - setting all dampening on camera rigs to zero, enabling rigid body interpolation and changing brain update mode to LateUpdate - for us that has solved a lot of issues with camera lagging/glitching.
     
  16. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,724
    Setting all damping to zero is a very heavy-handed fix, and curtails much of the value of Cinemachine. As far as we know, this should never be necessary, as there is always a more correct solution. It's true that damping reveals framerate problems. It is much better to fix them at the source, if at all possible, than to just cover them up by removing damping.
     
  17. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,724
    @ashdev18 Can you send me this project? I'd like to understand where those glitches are coming from.
     
  18. Kinnith7

    Kinnith7

    Joined:
    Jul 4, 2017
    Posts:
    84
    @ashdev18 I have returned home and pulled up that project. It's actually part of a project I am still working on now (yea, I'm slow, I kno..anyway), My problem was that I had a spaceship traveling at high speed, and when I would rotate the camera around to the front of the ship, (Like I am looking backward and the ship is coming at me), the ship would jitter badly. MUCH worse than in your video. I seem to have fixed that problem. I think it was a glitch with CineMachine and I just reinstalled Cinemachine and it went away. But now that I reload the test project and test it, I see that when I zoom in close to the ship at high speed, as you do with your car above (ie: have a 3rd person camera set close to the vehicle), I still have a bit of jitter, just as you do, from that same angle. So I am curious to see what the Unity tech @Gregoryl can come up with for you. Please share it here when you do. Sorry, I am not more help.
     
  19. ashdev18

    ashdev18

    Joined:
    Aug 2, 2020
    Posts:
    12
    sure i will share it here. Thank you @Kinnith7 . and can anyone tell me how to enable notifications for these threads and can i connect with any social media app like twitter And also how to mention someone here.
     
  20. ashdev18

    ashdev18

    Joined:
    Aug 2, 2020
    Posts:
    12
    I will send you project. And more about the issue : when i started project and used cinemachine the bug wasn't there. and as time pass it occurred. And when i had discord opened or recording with obs it happens more. i have noticed this several times happening with other projects as well. i think it might be some kind of cache issue.
     
  21. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,724
    @ashdev18 Thanks for the upload.

    First of all a couple of notes about your use of Cinemachine:
    • You have the main camera (with the brain) as a child of the vcam. That's not best practice. Instead, the main camera with the CM Brain should be a separate game object, not a child or parent of any virtual cameras. The job of the CM Brain it to track the current active vcam, so no parent/child relationship is needed. That's how you can activate different vcams and get cool blends.
    • Your camera looks and behaves much better if you change the Transposer's Binding Mode to SimpleFollowWithWorldUp (my opinion only).
    Now about the jitter. That it increases when your computer is doing other things is telling. It means that Unity's frame rate is not steady, and this confuses the damping. You can alleviate this problem considerably if you define CINEMACHINE_EXPERIMENTAL_DAMPING in your player settings. Try it and let me know how it works for you.

    upload_2022-8-27_16-36-34.png
     
  22. ashdev18

    ashdev18

    Joined:
    Aug 2, 2020
    Posts:
    12
    Replying to cam parent thing : i tried with seperating cam and vcam objects. And result was same. I will try the experimental damping and let you know later.
     
  23. einWikinger

    einWikinger

    Joined:
    Jul 30, 2013
    Posts:
    97
    Yes, that may be right, but for us it even exaggerates issues, e.g. if for some reason a frame takes twice as long as "usual", you not only get a slight hitch for a single frame, but it has a effect over multiple frames just because the camera is wobbling around to play catch-up for some reason, even though everything in-game moves smoothly :-/
     
  24. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,724
    Does the CINEMACHINE_EXPERIMENTAL_DAMPING fix address this issue for you?
     
  25. ashdev18

    ashdev18

    Joined:
    Aug 2, 2020
    Posts:
    12
    it did not fix for me.
     
  26. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,724
  27. ashdev18

    ashdev18

    Joined:
    Aug 2, 2020
    Posts:
    12
    It still does. while recording with obs... i think the problem is with interpolation on rigidbody. i set all to no interpolation and it was fixed. but without interpolation it doesn't look smooth motion. The problem is with all damping i also tried not using cinemachine and used animation rigging with damped transform. it was also bugging( just trying). with damping off on cinemachine it doesnt do that tho. but i need damping
     
  28. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,724
    Is it smooth when you just run my build normally, without OBS recording?
     
  29. ashdev18

    ashdev18

    Joined:
    Aug 2, 2020
    Posts:
    12
    yes
     
  30. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,724
    That's good. So the next questions are:
    1. what is OBS doing to the framerate?
    2. is the quality of the jitter different when you compare my version + OBS recording vs your version + OBS recording? If so, can you describe it?
     
  31. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,724
    I made a recording of my build with OBS and it's smooth. I doubt that this is a Unity issue. Do you get jitter when you try to record other high-speed games?
     
  32. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,724
  33. ashdev18

    ashdev18

    Joined:
    Aug 2, 2020
    Posts:
    12
    obs reduces framerate a bit. i played forza horizon 4. had no issue while recording with obs(70fps with high quality setting). my laptop : AMD Ryzen 9 5900HX with rtx3060, RAM - 16GB.
    by the way my friend also played my build and he also had this issue while screen sharing on discord.

    my build : https://drive.google.com/drive/folders/1SqSo3wrAKKPcOii1XkjnVHy5hB_Fx1Ai?usp=sharing
     
  34. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,724
    I am getting jitter with your build, even without OBS recording. It's as if you don't have the define set. Can you make a new build, and verify that you have the define properly set?
     
  35. ashdev18

    ashdev18

    Joined:
    Aug 2, 2020
    Posts:
    12
    what is the define?
     
  36. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,724
  37. ashdev18

    ashdev18

    Joined:
    Aug 2, 2020
    Posts:
    12
    i uploaded another build in same link. please check.
     
  38. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,724
    That's better. No jitter, and my computer is grinding away at something in the background. Does that version jitter when you OBS record?
     
  39. ashdev18

    ashdev18

    Joined:
    Aug 2, 2020
    Posts:
    12
    yes.
     
  40. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,724
    Can you show me a recording with jitter?
     
  41. ashdev18

    ashdev18

    Joined:
    Aug 2, 2020
    Posts:
    12
     
  42. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,724
    I get a little jitter with my version when recording, but not as much as that. I will send you my updated version of your project by DM. Please make a build and try it.
     
  43. tatoforever

    tatoforever

    Joined:
    Apr 16, 2009
    Posts:
    4,369
    I also have the jitter when rotating a freelook camera (set to be updated in LateUpdate). But for me it happens at any speed. If the freelook cam is just moving the target and the camera is following, no jitter. If im rotating without moving the target, no jitter either. If however, I move the target and rotate the freelook camera it jitters I will get a video showing it.
    Also, it's normal that freelook camera won't move/follow/update unless selected (hierarchy/inspector)?
    PS: Unity 2019.4.40f1 and CM 2.9.1
     
    Last edited: Sep 7, 2022
  44. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,724
    No it is not normal. Something is wrong with your setup. Can you show your hierarchy, including the main camera, FreeLook, and target? Also please show inspectors. A video of the jitter would definitely help.
     
  45. tatoforever

    tatoforever

    Joined:
    Apr 16, 2009
    Posts:
    4,369
    Here's the video showing the issues:

    I have the brain attached to the main camera (_PlayerCamera) and a freelook camera called _PlayerCameraFreeLook with a CinemachineCollider component. All those components are disabled by default, only enabled at runtime after feeding their target data. You can see the freelook camera won't get enabled by default. If the camera becomes unselected it will stop updating (same as when I hit Play).
    You can see the jitter in the character when walking sideways, this doesn't happen with my camera controller.
    Also not seen in the video is the camera collision. The cinemachine collision component is quite unstable. It shows similar issues i had when implementing my own camera collision with the push camera forward setup (jumpy back and fort when colliding). I can record a video to show mine vs cinemachine collision one to compare.
    [EDIT]
    Solved the inactive vcam issue by setting the vcam as the same layer as the brain. However the jitter issue remains.
     
    Last edited: Sep 7, 2022
  46. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,724
    Can you enable this setting and then run the scene? CMBrain will show the current active vcam in the top-left of the game view. What is that camera? If its priority isn't lower than your FreeLook's, then it can take control.

    upload_2022-9-7_13-46-18.png

    For the jitter, how are you controlling the axis values of your FreeLook? I don't see anything in the Input Name field.
     
  47. tatoforever

    tatoforever

    Joined:
    Apr 16, 2009
    Posts:
    4,369
    I only have one vcam, the freelook one you see in the video. But the issue got solved by puting the vcam to the same layer as the brain.
    The movement is controlled by script in LateUpdate, like so:
    var axisValues = new Vector2(Input.GetAxis("Right Stick X"), Input.GetAxis("Right Stick Y"));
    freeLookCam.m_XAxis.m_InputAxisValue = axisValues.x;
    freeLookCam.m_YAxis.m_InputAxisValue = axisValues.y;
    About the jitter. Here are two videos to compare my camera controller vs cinemachine controller.
    My camera controller:

    Cinemachine controller:

    Is very hard to notice on the video, but you can look at the lamp and see how it clips/snap while in my camera controller video is all smooth.
    And this is on my PC with high FPS. On Nintendo Switch hardware is horrible, is like the video in this thread of the car going at high speed only that my character is moving normally. :p
     
  48. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,724
    I don't see any jitter in the video, but I do see that the CM camera is bobbing up and down along with the player when he walks. Is that what you're talking about? This is because the LookAt target is the character's head, and the head bobs up and down due to player animation. You can fix this in any of a number of ways:
    • Don't look at something attached to the animated skeleton. Instead, look at the root but with a vertical offset, or look at an empty GameObject child of the player, not attached to the animated skeleton
    • Increase the Composer's damping (in all 3 rigs of the FreeLook)
    • Add a small dead zone to the Composer (in all 3 FreeLook rigs)
    As an experiment, can you temporarily change the Brain's UpdateMethod to SmartUpdate, run the game and while the player is moving look at the FreeLook inspector. Tell me what the update mode of the FreeLook is. It is displayed next to the Solo button.

    upload_2022-9-7_14-45-1.png
     
  49. tatoforever

    tatoforever

    Joined:
    Apr 16, 2009
    Posts:
    4,369
    The jitter very hard to notice in the video, maybe the recording does some sort of interpolation with frames? In my editor is a bit more visible but on Nintendo Switch hardware is really really noticeable.
    If I increase the damping the catchup to follow will take forever and I can get some bad camera angles where the player can't see where he's heading. I need almost no damping at all hence why the lack of dead zone.
    Changing the LookAT to a transform that is not animated (ex: the root of the character that holds the bones hierarchy and skinned meshes) does nothing either. Changing the brain from LateUpdate to SmartUpdate does nothing either. The jitter still there no matter what.
     
  50. tatoforever

    tatoforever

    Joined:
    Apr 16, 2009
    Posts:
    4,369
    Worth mention too, the performance hit is also high compared to my camera controller. I know there's a lot of things going on with the brain and the vcams but is there any part of the Cinemachine that is multithreaded?