I have an object that is being moved by setting its velocity. The Rigibody doesn’t have interpolation set. Meanwhile I have a Cinemachine Virtual Camera set to Transposer (Lock to Target No Roll) with some dampening applied and follow offset. The Aim is set to Hard Look At
Now my issue is that the camera is stuttering quite a bit. At first I thought it was the object itself but when I switch to the scene view, the object is moving smoothly and the camera seems to jump around.
I tried to switching update modes on Brain to various combination but it didn’t help. Same with Standby Update.
Any idea what can I do to get it to smoothly follow its target without this stutter?
If you set the Brain’s Update Method to Smart Update, then play the scene and look at the virtual camera’s inspector while the game is playing, what text do you see here?
That is what I see in the scene, it moves smoothly. Can I send the project (nothing more than the movement) in a PM please because it uses some paid assets from the store?
I’m definitely seeing some stutter when playing in the editor. I believe that this is due to the discrepancy between the physics framerate and the render framerate. You will get aliasing, which is magnified by 2 things:
Running in the Editor, which has a lot of extra overhead, making the render framerate more uneven. To get a more accurate idea of the situation, you should test a build of the project. When I do that, the stuttering is very considerably less.
Using Damping on the camera. Unfortunately, damping is very sensitive to uneven frame rates, and the stuttering will be amplified by this. One way to mitigate this is to reduce the aliasing by increasing the physics framerate. When I changed the Fixed Timestep (in ProjectSettings/Time) to 0.01 it was quite smooth in the build.
On a side note, changing the vcam’s Aim to Composer (with default values) made the camera very sweet.
Thanks a lot for the information. I think I’ll go with the Composer for now given it feels very smooth and good. But is there anyway to fix this in editor? It is very annoying to test with this jumping behavior the camera has.
That said, how can the editor mess up the smoothing so much? Nothing drastic is running that it takes so much time to render things or am I misunderstanding what you meant?
A shorter fixed timestep definitely helps in the editor too. Don’t make it too short, or you’ll kill performance.
The editor is a big complex program and it does lots of stuff, even if there’s not much in your scene. The build, on the other hand, is 100% focused on the game.
Smooth camera movement with an uneven framerate is a hard problem: because it’s the camera, any little glitch in its smoothness results in a hugely visible artifact, which our human brains are very much tuned into detecting. Putting some effort into guaranteeing a smooth framerate would be a rewarding investment.
Update: I thought of something this morning and had another look at your project.
Your player is being driven on the physics clock, but your script is tinkering with the velocity on the render clock. That’s a problem. So I changed PlayerInput.Update() to PlayerInput.FixedUpdate(). Then, everything was perfectly smooth in the editor, even with the physics timestep at its original value of 0.02. Setting the timestep smaller was just covering up the real problem.
You can even increase the timestep further and, if you want, you can enable rigidbody interpolation on the player to smooth it out. It all works quite well.
The take-home message is that you have to be very careful with physics-driven objects to consistently alter the movement only in FixedUpdate, never elsewhere. Otherwise you’re liable to get judder.
I was going to post about it being smooth when I was moving the object using Transform.Translate then I thought, maybe this is an Input issue given I forgot to change that part. Then I came in here to say this only to see you’ve spotted it. Thanks a lot for the heads up.
Thank you so much! This fixes all my problems! And prompts to you for making the Cinemachine, my brother! I learned a lot by reading the source code of the cinemchine
Sorry to necro, but i can’t figure this out. It says "Fixed update"but it stutters a lot on vertical movement. I tried turning off the old script i had that was altering the camera’s position as well as freezing the player’s movement, but it still stutters. Pretty sure i’m not taking camera input from any other scripts, it’s strange…
Did i set one of these settings wrong? If i change the decel/accel time it doesn’t seem to do anything.