Camera Stutter Issue

Explanation

For context, I have been working on this issue for a while now and I am still extremely confused on how it is happening; if I knew the exact cause I could make a proper solution.

I am attempting to update the camera’s position to make it smoothly follow a Part moved via BodyVelocity. However, there is a horrible stutter (even more noticeable with rotations) when I try to do this. And just to clarify it is the camera stuttering, not the object.

Didn’t Work


These solutions looked promising, but unfortunately did not work.


It’s kind of hard for me to explain the issue because I do not fully understand it. If anyone knows more about this it would be a massive help if you could help me understand the reason for the camera stuttering.

Here is a repro file for the stuttering (just run it in Play mode):
CameraStutterRepro.rbxl (26.7 KB)

EDIT: I do not completely understand the internals of the task scheduler and such, so explanations for that would also be pretty helpful.

I tried running it without changes and it seems to run just fine for me, what do you mean by stuttering? Do you mean that it is always behind the part a bit or…?

If you look at the Part it seems to jump back and forth (but it’s the camera). If it ran fine for you would you mind sending a video so I can see for myself. All of the tests that I have done produced stutter.

Example of mine: https://gyazo.com/a9632a7e3b89cd2cc0ae8e3edf080bb3
running at 60fps

I take my words back, it did run fine but it stutters here and there, additionally when i unfocus studio it starts shaking alot.

That aside, i tried using VectorForce instead as BodyVelocity is generally a legacy body mover but it did no difference. This is incredibly weird!

Edit: The server sees it too and i also tried letting the client control the simulation of that part (set network ownership), it made zero difference.

Even if Roblox’s physics was perfectly smooth (this is the issue for why you’re seeing this “stutter”), I still wouldn’t rely on setting the camera to a set offset from the part. Add a spring to the camera and you’re done. This smooths it out. You can also spring just numbers, instead of Vector3s like in my example below.

You can get a feel for the spring’s parameters, like damping and angular frequency on this demo: Spring.lua. The damping is how “bouncy” the spring is, and the angular frequency is how fast it reaches its target (d and s respectively in that Desmos link).

Using something like Validark’s spring.lua, you’d achieve this with the following method, every frame:

  • Set the target position to your cube position + your offset (just like you’re doing now, but there’s no reason to use CFrames)
  • Call update on the spring with the RunService delta-time.

In the past I have tried smoothly moving the camera with Lerp, SmoothDamp, and springs. They still result in the stuttering movement. I can try it again, but I doubt it will do much.

The stuttering was probably caused because of insufficient dampening or angular frequency to your spring.

But what is the actual root cause of the stuttering in general?

Roblox physics won’t ever be perfectly smooth - it’s not something you can solve. Also, if your cube went over some bumps, you’d get some pretty rough results without something like a spring. Lerping this won’t solve it, as it doesn’t smooth anything out.