Hover car physics stuttering?

Oh wow, it completely eliminated the jutter for me

Yeah so here is what is happening:

ROBLOX has internal physics steps (lets call these WorldSteps) running at 240Hz. A higher level physics job (lets call it PhysicsStep) runs at 60Hz.

When PhysicsStep runs, we try to see how much time has passed between now and last time PhysicsStep ran. Most of the time it will be 0.0166666 seconds or so. (Smooth 60Hz). When that happens, we say that for every 0.00416666 seconds of time we want to do 1 world step. For a smooth 60Hz step this will end up 4 world steps, which ends up running at 240Hz.

Occasionally what happens is some frame-rate fluctuates (Render is actually the thing that sets the timestamps for frames), and because of how frames got pushed around (due to rendering taking a bit longer, maybe), you notice that the time between the current and last PhysicsStep is only 0.015 seconds. This isn’t enough time to fit 4 x 0.004166665 second steps, so instead we will only run 3, which means we only do about 0.012499995 seconds of simulation. This usually means that next PhysicsStep will also do 5 world steps to compensate for the missed one, doing another small discrepancy between physics simulation dt and render dt.

This system is responsible for Physics/Game Logic staying real time when FPS drops below 60.

Since you’re using RenderStepped dt you can be seeing 0.0166666 second spring simulations for only 0.012499995 seconds of physics simulation.

So summary, we had 3 sources of Jitter:

  1. RenderStepped priority was set to the same as Camera, which means sometimes camera script updates before and sometimes after the Camera renders.
  2. Studio bug with Engine scheduling of Tasks.
  3. Simulating spring-dragged camera using Rendering dt instead of Physics dt.

EDIT: By the way I disabled the feature that was causing the Engine Scheduling issue (on Studio only). So you should be able to have the same smooth behavior in Studio and when running with Player.

29 Likes

Very interesting and in depth explanation and also very much appreciated! Thanks for looking into this and providing a solution. I’ve been using a ‘hacky’ method of getting the camera to follow my car and it’s been quite a pain due to the latency and other issues it produces but now with this information I’ll be able to use the critically damped spring to pull it off much more efficiently. I also notice that the result is the same in studio now, most likely since you disabled the feature that was causing the scheduling issue in studios.

Thanks again, this was all super helpful and I’m sure others will find it helpful when making a similar spring-dragged camera!

1 Like

These files are all locked now, however the solution code of the thread problem lies in there, please reupload or make the Roblox place available, will be a massive help.

1 Like

All the solution files have been taken private. Would it be possible for you to share them again?

I downloaded the file back when it was available:
JudderRepro-UseRunServiceSteppedDtInsteadOfRenderStepped.rbxl (414.9 KB)

6 Likes