Jitter with cinemachine (Solved)

Hi, I’m working on my first game in unity and I’m trying to use cinemachine to follow the player (a happy blue circle) who shoots enemies (red angry squares) with his happy assault rifle, problem is I get a lot of jitter when I move around using the default cinemachine follow settings. I tried using extrapolate and interpolate (on the player) but to no effect because the issue is clearly not the player (video when the camera doesn’t follow the player: 2022-12-20 22-34-53.mkv ), when the camera is not following the player, the player moves smoothly.
(video when the camera follows the player: 2022-12-20 22-41-58 )
I also noticed the enemies were lagging whenever the player gets to the edge of the deadzone.
(Ignore the unpolishness of my game for the moment)

-This is not a frame rate issue, i am registering 400+ fps
-I tried lowering the damping settings and similar options in the cinemachine settings but then my weapon sprite starts jittering from time to time
-The player is moving using the MovePostion on the rb2d
(image of code bellow)

Your code looks correct.
I’m not seeing significant jitter, nor am I seeing any camera movement.
Do you see jitter in the build, or just in the editor?
What version of Unity and Cinemachine are you using?
And finally, it’s not necessary to use all caps or bold when posting here. Normal text is enough.

Thank you for the reply, I’m using Cinemachine 2.8.9 and Unity 2021.3.14
The build version has identical issues. If you look closely at the second video you can see jitter when the player is at the edge of the deadzone. This has been a long time issue since I started this project and I haven’t found a way to solve it.
As for the camera movement it may seem like its not moving because of the empty background but in the second video im continuously moving to the edge of the deadzone, trying to show the jitter.

I really don’t see the jitter, and I don’t know where the dead zone is.
Can you show me your inspectors for

  • CM Brain
  • Virtual Camera
    Please snapshot the the vcam inspector while the game is running.
    Also please show a picture of your hierarchy so I can see the relationship between vcam, player, and main camera.


8676693--1169508--upload_2022-12-21_0-36-35.png

8676696--1169511--upload_2022-12-21_0-39-51.png

These are the default settings of my cinemachine.

8676705--1169517--upload_2022-12-21_0-43-2.png

I can also show you a temporary fix I found when I set my damping and deadzone to 0:
8676714--1169520--upload_2022-12-21_0-45-41.png
The problem with the above settings is that there is still some partial jitter when I move in any direction and my mouse doesnt move, the weapon jitters, just like the player.
If i remove the cinemachine and repeat the process the problem disappears.

What happens if you unparent the vcam from the main camera? They should be separate gameobjects, not parented to each other.

I just tried, same problem.

Are you willing to send me your sandbox project? I can take a look at it.

When I set damping and deadzone to 0 everything moves smoothly, I just figured out that the weapon renderer wasnt setup correctly and that was causing the weapon jitter, the problem still persists whenever I increase damping. I want to make a dynamic camera movement in the future so while this fix may work at the moment I want to know what changes I could implement to remove the jitter when there is a deadzone.

Ok, I’m uploading it to a git.

Do I send the root or the whole project? Sorry, I’m still not familiar with how exactly the engine loads a project.

You need to share Assets, Packages, ProjectSettings, and UserSettings folders. Don’t send the rest, Unity can regenerate it.

Thanks for the upload. I found the problem.

While the code you posted above for the player movement is correct, there is another piece of code (shoot.cs) that sets the player’s transform.rotation in Update(). This creates jerky movement in the player, and it becomes impossible for the camera to follow it smoothly with damping.

When you use RigidBodies, it’s important to never set their transforms. Instead, always use rb.MovePosition and rb.MoveRotation, and do that in FixedUpdate, never in Update.

If you follow these rules, the camera tracking will be smooth. Also, you’ll be able to enable Interpolation on the rb and it will be even smoother. Right now, interpolation has no effect because you’re touching the transform.

After you fix that, you can then use the FramingTransposer with damping and it will look very nice.

5 Likes

Thank you very much!

2 Likes