Search Unity

Cinemachine - Crazy jitter

Discussion in 'Cinemachine' started by Shapefarm, Apr 12, 2017.

  1. patrickjarnfelt

    patrickjarnfelt

    Joined:
    Jun 24, 2013
    Posts:
    28
    So I have an issue that has been introduced in 2.4.0+ (and I have confirmed that it is not a problem in 2.3.4).
    When I have a VCam Trigger (VCam2) within a VCam Trigger (VCam1) that goes back to the first VCam1 there is a noticable jump/jitter.
    Here is a video showing that going into VCam2 is no problem, going out and back to VCam1 it jumps:

    And the faster the movement the bigger the jump. I have Smart Update enabled and tried all the types.
    The cameras have the same priority and the latest enabled is then active (like I would expect). So when VCam2 gets disabled it should jump back to VCam1 smoothly, but this is not the case.

    It is working in 2.3.4 so I have reverted.

    Does anyone know what the issue could be?
     
  2. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,711
    Hey @patrickjarnfelt thanks for that. I'm having a little trouble understanding the setup.
    I'd like to take a closer look at this issue. Can you reproduce this in a small simple project and send it to me?
    Thanks.
     
  3. minad2017

    minad2017

    Joined:
    Dec 1, 2016
    Posts:
    50
    Hello.
    I am having trouble because small jitter cannot be eliminated by operating the rigidbody charactor using cinemachine.
    Thanks to this forum, I learned that lateupdate and interpolate can remove large jitter.
    but, small jitter is generated by the rotation of the character using Look At, and this cannot be solved.
    It works fine by removing the rigidbody, but my game requires a rigidbody, so I hope to somehow solve this problem.
    Is there a solution?
    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4. using Rewired;
    5.  
    6. public class LookAtDirection : MonoBehaviour
    7. {
    8.     public int PlayerID;
    9.     public string moveXname;
    10.     public string moveYname;
    11.     public GameObject owner;
    12.     public enum AxisPlane
    13.     {
    14.         XZ,
    15.         XY,
    16.         YZ
    17.     }
    18.     float horizontalAxis;
    19.     float verticalAxis;
    20.     public float multiplier = 1.0f;
    21.     AxisPlane mapToPlane;
    22.     public GameObject relativeTo;
    23.     float storeMagnitude;
    24.  
    25.     Vector3 targetDirection;
    26.     float minMagnitude;
    27.     Vector3 upVector;
    28.     public bool keepVertical = true;
    29.     public float speed;
    30.     public bool fixedupmode;
    31.  
    32.     public float AnimationDamptime = 0.2f;
    33.  
    34.     GameObject previousGo;
    35.     Quaternion lastRotation;
    36.     Quaternion desiredRotation;
    37.  
    38.     //Rigidbody m_Rigidbody;
    39.     Animator m_Animator;
    40.  
    41.     protected Player Player
    42.     {
    43.         get
    44.         {
    45.             return ReInput.players.Players[PlayerID];
    46.         }
    47.     }
    48.  
    49.  
    50.     // Start is called before the first frame update
    51.     void Start()
    52.     {
    53.         m_Animator = owner.GetComponent<Animator>();
    54.  
    55.     }
    56.  
    57.     void FixedUpdate()
    58.     {
    59.         if (fixedupmode)
    60.         {
    61.             SmoothLookAtDirection();
    62.         }
    63.     }
    64.  
    65.     // Update is called once per frame
    66.     void Update()
    67.     {
    68.         GetInput();
    69.         MoveCharactor();
    70.  
    71.         if(!fixedupmode)
    72.         {
    73.             SmoothLookAtDirection();
    74.         }
    75.     }
    76.     void GetInput()
    77.     {
    78.         horizontalAxis = Player.GetAxis(moveXname);
    79.         verticalAxis = Player.GetAxis(moveYname);
    80.  
    81.         var forward = new Vector3();
    82.         var right = new Vector3();
    83.  
    84.         if (relativeTo == null)
    85.         {
    86.             switch (mapToPlane)
    87.             {
    88.                 case AxisPlane.XZ:
    89.                     forward = Vector3.forward;
    90.                     right = Vector3.right;
    91.                     break;
    92.  
    93.                 case AxisPlane.XY:
    94.                     forward = Vector3.up;
    95.                     right = Vector3.right;
    96.                     break;
    97.  
    98.                 case AxisPlane.YZ:
    99.                     forward = Vector3.up;
    100.                     right = Vector3.forward;
    101.                     break;
    102.             }
    103.         }
    104.         else
    105.         {
    106.             var transform = relativeTo.transform;
    107.  
    108.             switch (mapToPlane)
    109.             {
    110.                 case AxisPlane.XZ:
    111.                     forward = transform.TransformDirection(Vector3.forward);
    112.                     forward.y = 0;
    113.                     forward = forward.normalized;
    114.                     right = new Vector3(forward.z, 0, -forward.x);
    115.                     break;
    116.                 case AxisPlane.XY:
    117.                 case AxisPlane.YZ:
    118.                     // NOTE: in relative mode XY ans YZ are the same!
    119.                     forward = Vector3.up;
    120.                     forward.z = 0;
    121.                     forward = forward.normalized;
    122.                     right = transform.TransformDirection(Vector3.right);
    123.                     break;
    124.             }
    125.         }
    126.  
    127.         var h = horizontalAxis;
    128.         var v = verticalAxis;
    129.  
    130.         var direction = h * right + v * forward;
    131.         direction *= multiplier;
    132.  
    133.         targetDirection = direction;
    134.         storeMagnitude = direction.magnitude;
    135.     }
    136.  
    137.     void MoveCharactor()
    138.     {
    139.             //  m_Animator.SetFloat("inputX", targetDirection.x, AnimationDamptime, 0f);
    140.             m_Animator.SetFloat("inputY",storeMagnitude, AnimationDamptime, Time.deltaTime); //set Animator Float
    141.     }
    142.  
    143.     void SmoothLookAtDirection()
    144.     {
    145.         if (previousGo != owner)
    146.         {
    147.             lastRotation = owner.transform.rotation;
    148.             desiredRotation = lastRotation;
    149.             previousGo = owner;
    150.         }
    151.  
    152.         var diff = targetDirection;
    153.  
    154.         if (keepVertical)
    155.         {
    156.             diff.y = 0;
    157.         }
    158.  
    159.         var reachedTarget = false;
    160.         if (diff.sqrMagnitude > minMagnitude)
    161.         {
    162.             desiredRotation = Quaternion.LookRotation(diff, Vector3.up);
    163.         }
    164.         else
    165.         {
    166.             reachedTarget = true;
    167.         }
    168.         lastRotation = Quaternion.Slerp(lastRotation, desiredRotation, speed * Time.deltaTime);
    169.         owner.transform.rotation = lastRotation;
    170.  
    171.     }
    172.  
    173.  
    174. }
    175.  
     
  4. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,711
    The jitter is due to the character being animated on both Update() and FixedUpdate().

    For RigidBodies, interpolation will convert the transforms to be compatible with Update - but it will only work if the character is being updated by the physics system. If you are manually animating the RigidBody, interpolation will have no effect. This is why you get the jittery rotations in your best settings - those rotations are not being interpolated.

    With FixedUpdate/no interpolation, you will probably get good results if you move the MoveCharactor() code to FixedUpdate.
     
  5. minad2017

    minad2017

    Joined:
    Dec 1, 2016
    Posts:
    50
    Thanks for the reply, I was able to delete the jitter with fixedupdate, but since the movement in the movie scene is built with normal update, the jitter will be included when switching to the camera for the movie.
    Isn't it possible to unify cameras with "LateUpdate" using rigidbody "interpolate"?
     
  6. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,711
    Interpolation only works if the RigidBody's transform is being generated 100% by the physics simulation. It simulates one frame ahead, and is then able to interpolate between the previous frame and the next frame to get the transform at the moment of LateUpdate, which will fall between them. If you are manually animating these things, then the interpolation cannot work, because you don't have the data for the upcoming frame.

    If you're animating the object on Update during the movie scene, then you must update the vcam also on LateUpdate during the movie scene, and furthermore make sure that the RB's transform doesn't change on FixedUpdate.
     
  7. minad2017

    minad2017

    Joined:
    Dec 1, 2016
    Posts:
    50
    I understood how interpolate works.
    I decided to rework the movie scene.
    Thank you for your prompt reply.
     
  8. minad2017

    minad2017

    Joined:
    Dec 1, 2016
    Posts:
    50
    Let me ask you another question
    I compared FreeLookCamera of LateUpdate with FreeLookCamera of FixedUpdate.
    When you move the camera, "LateUpDate" looks smoother.
    FixedUpDate seems to have a little afterimage.
    This is a very slight difference.
    Can this be fixed?
     
  9. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,711
    There is no general answer to this question. It depends on how the target is animating. Can you put together a small demo project that shows what you're talking about? I can look at it and see if I can understand the problem.
     
  10. minad2017

    minad2017

    Joined:
    Dec 1, 2016
    Posts:
    50
  11. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,711
    I looked at your project, and I'm finding that FixedUpdate is very smooth, but LateUpdate shows some small jitter when I move the mouse horizontally very fast. This seems to be the opposite of what you're seeing.

    For me, the FixedUpdate is very good. Did you test in a build, or just in the editor?
     
  12. minad2017

    minad2017

    Joined:
    Dec 1, 2016
    Posts:
    50
    It looked the same when build.
    The afterimage appears strongly not in the character but in the background.
    When you move the camera with fixedupdate, the background looks a little jerky and appears to be moving.
    This feels stronger when using Joystick than with a mouse, but it is a level that can be confirmed with a mouse.
    If you look at fixedupdate alone, you may not be bothered, but if you look at the smooth background movement of lateupdate, you will feel a strong discomfort.
    Attach the video, please play at 1080: 60fps
     
  13. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,711
    This is interesting, I will investigate further
     
  14. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,711
    I'm sorry, but I'm just not able to reproduce this juddering. It's perfectly smooth for me. I tried both ways, with a build, and with the editor. Unfortunately I don't have a working joystick at home, so I only was able to test with the mouse.

    Can you think of anything special about your setup?
     
  15. minad2017

    minad2017

    Joined:
    Dec 1, 2016
    Posts:
    50
    This phenomenon has been found to occur even with 2D cameras
    Even if you do not move the mouse, afterimages occur when you move the character.
    Changing the Unity version to 2019.3.9 did not improve.
    Updated to the latest graphic board driver, but did not improve.
    I tried it on a gaming laptop that I own, but the same symptoms appeared.
    I played the build package on a low-spec notebook PC without a graphic board, but the same symptoms appeared.
    Attach the build package.
    https://drive.google.com/open?id=1alMrn8_U1LegU20Xw0A_SNqojWIOKvp1
     

    Attached Files:

  16. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,711
    Does the effect go away when you turn *all* Cinemachine Damping settings to 0?

    Also: can you clarify exactly what you mean by "afterimages"? I'm assuming it means uneven background movement, but I'd like to be certain.
     
    cLick1338 likes this.
  17. minad2017

    minad2017

    Joined:
    Dec 1, 2016
    Posts:
    50
    All damping was turned off, but nothing changed.
    Yes, the background movement is uneven.
     
  18. minad2017

    minad2017

    Joined:
    Dec 1, 2016
    Posts:
    50
    It was found that when AxisControl, AccelTime and DecelTime of freelookcamera were set to 0, abnormal movement occurred at the time of FixedUpdate.
     

    Attached Files:

  19. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,711
    There seem to be 2 issues here:

    1. As the character moves in fixed update, the spaces between the rendered frames appear uneven, and they appear more even when the camera updates on LateUpdate. This unevenness is not affected by Cinemachine damping, and is unrelated to the axis orbiting, since it also appears when the the axis is not orbiting.

    2. In all update modes, axis is jumpy when axis accel/decel times are 0

    For number 1: I'm wondering whether this is a case of the difference between the physics framerate and the render framerate being too large. Is the the framerate really high? Do you get better results if you clamp your framerate to 60 or 90? (don't decrease the FixedTimestep too much or you will kill performance)

    For number 2: This is a known issue. Put very small values in accel/decel, but not 0. As an alternative, you can try changing axis mode, like this:

    upload_2020-4-9_18-27-24.png

    You'll have to lower speed (dividing by 10 or more is common). This mode dives a more direct feeling to the axis control. Many people like it better.
     
  20. minad2017

    minad2017

    Joined:
    Dec 1, 2016
    Posts:
    50
    FixedTimeStep was set to 0.0167 because it was fixed at 60fps. I tried returning it to the default of 0.02fps, but no big change was seen.
    My favorite was input value gain, but I also feel that it is not moving smoothly unless it is in LateUpdate environment. Unless AccelTime was raised to about 0.8, severe shaking occurred.
    At present, it seems difficult to completely solve the problem, so I would like to proceed with development as it is.
    Thank you very much.
     
  21. minad2017

    minad2017

    Joined:
    Dec 1, 2016
    Posts:
    50
    When fixedtime steps is set to 0.01666667
    The discomfort of the background has almost completely disappeared
    Thank you.
     
    Gregoryl likes this.
  22. klicpjan

    klicpjan

    Joined:
    Oct 2, 2019
    Posts:
    4
    Hello, I am as well having trouble with jitter. I have read through all of the previous replies, however, my setup is quite unusual and I am looking for advice whether it is even possible to remove the jitter.

    We are trying to create 2D stylized animations which are recorded using a green screen and stylized using EbSynth. In order to authentically replicate the walking animations, I have extracted the motion tracking data from Blender and applied them as distance during each frame update (each frame has a distance traveled value). I have an internal buffer which applies the collected distance sum to the transform of my player character every FixedUpdate call. I am not modifying the transform from anywhere else. Unfortunately, that causes noticeable jittering.

    As was discussed earlier, when damping is set to 0, the character stays perfectly still, but the background jitters. When damping is a non-zero value, the background is fine, but the character jitters. I have tried changing the Update method settings, tried moving the rigidbody instead of the transform, all sorts of rigidbody settings, none of it stopped the jitter though. Could the jittering be caused by the fact that the transform is not moved every FixedUpdate call during the animation? That happens when the frame rate of the animation is lower than the update rate of the FixedUpdate (the buffer gets incremented after each frame and added to transform in FixedUpdate). When I view the character using the scene window, it doesn't seem to jitter almost at all. Should I move the character in a different way, or is the way I am doing it completely wrong? Many thanks!
     
  23. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,711
    That is a symptom of the target not being animated smoothly. There is no magic setting that will fix this problem. The solution is to move the character smoothly. That means moving it by a smoothly-changing amount every fixedupdate. There is no other way.
     
    klicpjan likes this.
  24. klicpjan

    klicpjan

    Joined:
    Oct 2, 2019
    Posts:
    4
    Thank you for the reply, you were right, that was the root of the issue. I guess I was just naively hoping there would be some other solution. I have managed to somewhat fix the issue with a simple interpolation algorithm, which divides the distance into smaller roughly equal chunks which are applied every fixedupdate calls so that the character is animated smoothly.
     
    Gregoryl likes this.
  25. ksam2

    ksam2

    Joined:
    Apr 28, 2012
    Posts:
    1,079
    I need to set my character animator update mode as "Animate Physics" but CM camera shakes too much.
     
  26. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,711
    The camera will shake if there is a mismatch between the target animation clock and the camera animation clock, or if the target is not being animated smoothly. Make sure that the CM vcam is being updated on the same clock as the target.
     
  27. iDerp69

    iDerp69

    Joined:
    Oct 27, 2018
    Posts:
    49
    What exactly does adding CINEMACHINE_EXPERIMENTAL_DAMPING do? I was having severe jitter issues, trying a multitude of things to solve them, and adding that was among the more beneficial (although still not perfect, but I'm finding the minor stutters here and there much more acceptable and I think I can continue using CM in this project). I'm also on the alpha branch, and enjoying the delta time stability benefits that came in I think 2020.2.0a9.
     
  28. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,711
    @RZephyr07 It uses a different damping algorithm that's more stable in situations where the framerate fluctuates. However, it's more costly, so it's an opt-in experimental thing. Glad to hear that the deltatime stability work is showing results.
     
  29. Jeshira

    Jeshira

    Joined:
    Aug 3, 2017
    Posts:
    12
    I'm posting this for future generation!
    Cinemachine uses more than a single script. Look up your camera object, CinemachineBrain script, update method. Try FixedUpdate or LateUpdate. Feels like SmartUpdate isn't so smart. I had the jitter issue with Cinemachine and curiously it was solving itself when I "hit" the camera at Top or Bottom Rig a few times, then it stop jittering. Setting to FixedUpdate solved it from start (for now?)
     
  30. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,711
    Smart Update will auto-detect whether the target is moving on FixedUpdate or Update, and update the vcams on the appropriate clock. This will work if the target is being animated consistently and smoothly on either clock. If SmartUpdate is having trouble following the target smoothly, usually that is a sign that the target is not being animated smoothly, or is being moved a little on each clock, which is not conducive to smooth movement.
     
  31. Jeshira

    Jeshira

    Joined:
    Aug 3, 2017
    Posts:
    12
    So, if I just set CinemachineBrain to fixedUpdate and it stopped being jittery it would because I changed my movement code between the time I clicked the dropdown and clicked to Fixed? I don't type that fast, plus, it wouldn't explain why "smashing" the camera against top and bottom limit of Y Axis would make it stop being jittery.

    Anyway, just saying changing Update Method of CinemachineBrain might help some people.
     
  32. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,711
    I don't know why it stopped the jitter in your particular case. One possible explanation is that you have code that mostly changes the target's transform in FixedUpdate, but maybe some code also makes a negligible change in Update. That negligible change would be enough for SmartUpdate to decide to follow on the Update clock, which would be incorrect in this case. Changing brain's update method to FixedUpdate effectively tells it to ignore movement that occurs in Update().
     
    Jeshira likes this.
  33. Jeshira

    Jeshira

    Joined:
    Aug 3, 2017
    Posts:
    12
    I tried to look and the only thing I do in update is poll Input System, then move in FixedUpdate. Anyway I've moved on to a custom build camera controller so I can't really test or anything. Thanks, I'll try to be more careful to that detail in the future.
     
    Last edited: Dec 19, 2020
  34. vuqarahim

    vuqarahim

    Joined:
    Dec 4, 2020
    Posts:
    4
    Hello, @Gregoryl I dont know if anybody is gonna reply, but I have been experiencing some jittering too, but it only jitters when I rotate the camera, not on movement, I have set up an fps scene, and my input system is touch controls for mobile, so to get cameras rotation I used an extension for the virtual camera. I get my lookInput values on Update. and I have tried calling rotate function on Update, Fixed Update, it doesnt work.

    my character mesh animated with statemachine and it is childed to my Player Transform. and my Virtual Camera follow transform which I have childed to the head transform of my character mesh.

    I tried setting interpolation on and off. Setting animation physics. It didnt work. Im certainly doing something wrong but I dont know what, I hope somebody can help. Thanks in Advance

    -----------------------------------------------------------------------------------------------------------------------------------------------------

    using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;
    using Cinemachine;

    public class CinemachinePOVExtension : CinemachineExtension
    {
    TouchAim aim;
    Vector3 startingRotation;

    [SerializeField] float horizontalSpeed = 10f;
    [SerializeField] float verticalSpeed = 10f;
    [SerializeField] float clampAngle = 80f;
    public Quaternion rotation;

    protected override void Awake()
    {
    aim = TouchAim.instance;
    base.Awake();

    }
    protected override void PostPipelineStageCallback(CinemachineVirtualCameraBase vcam, CinemachineCore.Stage stage, ref CameraState state, float delta)
    {
    if (vcam.Follow)
    {
    if (stage == CinemachineCore.Stage.Aim)
    {
    if (startingRotation == null) startingRotation = transform.localRotation.eulerAngles;
    Vector2 deltaInput = aim.lookInput;

    startingRotation.x += deltaInput.x * horizontalSpeed * Time.deltaTime;


    state.RawOrientation = Quaternion.Euler(transform.localRotation.eulerAngles.y, startingRotation.x, 0);
    rotation = state.RawOrientation;
    }
    }
    }
    }
    ------------------------------------------------------------------------------------------------------------------------------------------------------------

    then I use this value to rotate my player on my player script.

    I uploaded the camera values too


    for the the jitter be visible I moved the target transform behind the player.
     

    Attached Files:

  35. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,711
    @vuqarahim Can you make a small sample project that has the issue and send it to me? Jitter can be caused by many things, and it's difficult to diagnose just from a description.
     
  36. beneQ_04

    beneQ_04

    Joined:
    Mar 1, 2020
    Posts:
    21
    Hi, I have been struggling to get rid of jittery sprites in my game. I've been pulling my hair out for past 4 weeks trying to fix this issue. So I cooked up a small show case project with my player that can only move left and right. I'm using a state machine to handle my player and only states that I included in this project is idle and move state. I'm also using cinemachine and pixel perfect camera and my jitter appears only when my player starts moving. I'd appreciate if you could take a look at it @Gregoryl

    here is link to the project zip file: https://drive.google.com/file/d/1qxWdmzwIZkBmukhy4x7aFuZgkVYEOB7E/view?usp=sharing

    Also if you need any more info about anything let me know.
     
  37. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,711
    @beneQ_04 Thanks for the upload. The jitter disappears when I disable the PixelPerfect component on the main camera. I think the problem lies with that component. You might want to ask on the URP forum.
     
  38. beneQ_04

    beneQ_04

    Joined:
    Mar 1, 2020
    Posts:
    21
    Last edited: Jun 28, 2021
    ihgyug and Gregoryl like this.
  39. SonicTheHedgiehog

    SonicTheHedgiehog

    Joined:
    Nov 15, 2020
    Posts:
    20

    I Had same with sonic physics and fixed it by setting "Update Method" component to "FixedUpdate" instead of "Smart Update" , in the CinemachineBrain On Main Camera.
     
  40. adamstepinski

    adamstepinski

    Joined:
    Aug 7, 2015
    Posts:
    57
    In my case it was bad parent: cinemachine camera was child of moving object
    make sure virtual camera is under scene root
     
    Last edited: Nov 10, 2021
    Gregoryl likes this.
  41. alti

    alti

    Joined:
    Jan 8, 2014
    Posts:
    94
    changing the cinemachine brain update method to late update (blending mode too) fixed the jitter for me.
    I assume this happens for people who are using timeline for animations, and that unity uses an override for the animation to show. The "look at" may be fighting between those two targets (the idle they are in the BG, and the override they're playing in the scene). It stands to reason late update would be the way to go with this in mind. Worked for me!
     
  42. Dobalina

    Dobalina

    Joined:
    Sep 6, 2013
    Posts:
    105
    Hey @Gregoryl I have an odd character jittering issue I've been trying to solve for days, it's not fully clear to me if it's a unity issue or Cinemachine issue. Oddly my problem only arises when the scene is reloaded and whilst steering my character.

    My setup:
    • I have a transposing camera that follows a rather simple character that uses a looping run animation to move them forward.
    • I steer the character by applying a smooth "look at" towards a vector 3 hit point, which originates from a mouse click raycast.
    • My character has a rigidbody with interpolate on.
    • The rigidbody has all its rotations frozen so is to prevent the character from falling over
    • It's Animator with update mode "normal".
    • My camera brain update is "Smart Update" and the blend is "Late Update"
    • I'm on Cinemachine 2.8.4 and on the standard render pipeline 2020.1.11

    Issue:
    When I launch my gameplay scene, either in a build or editor, everything is very smooth with no jitter anywhere. It's exactly how I want it... but if I exit the gameplay scene, load the mainmenu, then load back into the gameplay scene (Async loading), now my character jitters but only when I steer the character with the smooth look. It's weird because the first play session of the scene runs flawless, any subsequent scene loads will have character jitter. All of the settings I mentioned above are the same between loads. The only way I can stop the character jitter in subsequent loads is by removing the smooth look at, or used fixed update (but this results in a smooth character with a stuttering world)

    Any thoughts on this or suggested areas I should look into?
    Does cinemachine have issues with Async loading that might result in this?
     
    Last edited: Apr 7, 2022
  43. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,711
    Doesn't sound like a Cinemachine problem. It sounds more like an unsmooth-animation problem. Maybe after the async load your framerate is dramatically different, and reveals an existing problem that was hidden under a faster framerate? Can you check that?

    Also what happens if you turn the vcam's damping to 0? (just as a diagnostic - I'm not suggesting that you keep that setting)

    And finally, what happens if you replace the vcam by a naive camera script that tracks the character using SmoothDamp? (again as a diagnostic)
     
  44. Dobalina

    Dobalina

    Joined:
    Sep 6, 2013
    Posts:
    105
    I have a high 60+ fps in playthroughs and doesn't seem to be a performance related, evident when the character runs straight forward and everything is nice and smooth. Only when I reload the level and steer my character (smooth look towards a vector3) is when the jitter occurs.

    Setting dampen to 0 seemed to make the camera stutter with the character, but it was hard to tell exactly.

    One thing I just discovered is that all the jittering goes away if I have the Animator panel open or if I have Inspector open with an animation playing. With any one of those up, the jitter is gone, if they're closed, the jitter comes back. I guess that means it's not a cinemanchine issue.
     
  45. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,711
    That's just weird. Can you reproduce the jitter in a build, or is it only in the editor?
    Also: it wouldn't be a bad idea to upgrade Unity to the stable LTS version (2020.3).
     
    Last edited: Apr 7, 2022
  46. Dobalina

    Dobalina

    Joined:
    Sep 6, 2013
    Posts:
    105
    Ah I figured it out! My physics timesteps didn't match with my time scale. The jitter was in both editor and build. So clearly this issue had nothing to do with Cinemachine. I know unity jitter is a hot topic, so luckily this exposes one more thing to check.
     
    Gregoryl likes this.
  47. Not_Unlike_Games

    Not_Unlike_Games

    Joined:
    Mar 1, 2021
    Posts:
    3
    Thank you!

    After troubleshooting the smooth path, dolly cart, and camera settings for like ever I came across this thread.

    Turns out my jitter was being caused by my aim target being Transformed every frame. (On Rails Space Shooter Controller)
     
    Gregoryl likes this.
  48. FrickinSilly

    FrickinSilly

    Joined:
    Feb 19, 2020
    Posts:
    53
    I read through this whole thread, but I don't see the issue I'm currently experiencing. I am getting camera jitter when moving from one camera to another (using a simple enable = true in the code). I don't think this has anything to do with animation, and each of the two cameras track the player smoothly. It's only when switching from one camera to the next that causes a brief jitter. There's no rotation at all.

    Here's a clip of it occurring

    Note the player triggers the camera switch when touching a polygon collider. The gizmo is turned on so you can see the collider boundaries half way through the clip.
     
  49. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,711
    Can you show your CM Brain inspector? Also, can you show an image of the vcam inspectors while playing? On the top, it will indicate how it's being updated:
    upload_2023-5-9_10-31-7.png
     
  50. FrickinSilly

    FrickinSilly

    Joined:
    Feb 19, 2020
    Posts:
    53
    They both look to be updated using fixed update. Here is a more informative video with the inspectors for both virtual cameras. The Brain inspector is shown at the end of the clip. It looks like imgur drops a bit of the resolution, so let me know if it's too difficult to see and I'll try a better resolution image.

    Imgur

    Quick edit to add: It looks as if the camera remains in the location it was disabled. When re-enabled, it is in that same location, but the player is already moving in the opposite direction. Lookahead smoothing put it so far ahead that when faced the other way, it's now so far behind. It still wouldn't explain why the "catch-up" period is jittery and not smooth though
     
    Last edited: May 9, 2023