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

Cinemachine 2D camera jitters if Target moves too fast

Discussion in 'Cinemachine' started by DavidC02, Jun 26, 2018.

  1. DavidC02

    DavidC02

    Joined:
    Jul 19, 2011
    Posts:
    152
    When the character is moving too fast (Sonic fast) the camera stutters and looks a bit weird. After playing around with the component setting Damping on both X and Y to 0 makes the jitter dissapear, but I'd like to have Damping. Any suggestions?

    All character movement is done on FixedUpdate and Interpolate on the 2D component is set to None.
     
    Last edited: Jun 26, 2018
  2. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,658
    1. Which version CM and which version of Unity?
    2. What happens when you set the Brain's update mode to Fixed Update?
     
    TheRealOgPlayer likes this.
  3. DavidC02

    DavidC02

    Joined:
    Jul 19, 2011
    Posts:
    152
    1. 2.2.0
    2. Still happens, but if I change the Fixed Timestep value from 0.02 to 0.01 it stops happening, but was hoping for this to not be the fix.
     
  4. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,658
    Damping jitter can happen when the character is not moving smoothly, because the damping amount is based on the character's position on the previous frame, and if the steps are not even, the damping will be uneven and won't match.

    So the question becomes: why is the character not moving smoothly at high speeds? Could this be a precision issue? Could it have to do with the character being very far away from the origin? (floating-point precision degrades as the numbers get large)

    It might be interesting to dump the character positions when this is happening and plot them on a graph to see if the motion is smooth.

    One possible workaround is to lower the camera damping at high speeds.
     
    mukundmagdum3 likes this.
  5. DavidC02

    DavidC02

    Joined:
    Jul 19, 2011
    Posts:
    152
    We noticed the distance traveled was different every second, but it also happens on the PennyPixel demo. We do use velocity to move instead of the transform but seems like the issue is present on the demo as well.
     
  6. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,658
    I'm not familiar with the PennyPixel demo.
    I'd like to look into this a little more, to figure out what's going on. Can you upload a simple project that demonstrates this problem? Maybe we can find a solution for you.
    Thanks
     
  7. popperur

    popperur

    Joined:
    Feb 10, 2017
    Posts:
    2
    Not sure if this is helpful to anyone, I had the same issue in my 2D platformer attempt with custom physics, similar to the PennyPixel one (implemented here: https://unity3d.com/learn/tutorials/topics/2d-game-creation/player-controller-script), also with parallax effect with perspective camera, and for me the solution was to set the Brain's update mode to "Late Update". This fixed all the jittering / stuttering issue I had.
     
    CJ_Smith likes this.
  8. TheRealOgPlayer

    TheRealOgPlayer

    Joined:
    Feb 26, 2022
    Posts:
    1
    You sir have helped me more then you know. Took me hours to find this.
     
    Gregoryl likes this.