Currently, as of 12/19/24, DeltaTime (as seen in events like RunService.Stepped) is extremely unreliable at lower framerates.
DeltaTime in other engines is often used to make framerate-independent game mechanics. However, DeltaTime on Roblox cannot be used reliably for this purpose, as it provides inaccurate values at lower framerates.
Steps to reproduce:
Open the repro place file attached to this bug report
Run a playsolo session at 144 FPS.
Hold the LeftShift key. Observe that after 2 seconds, a os.clock() diff is printed and it has a value near 2.
Set studio’s framerate to 20 FPS. Repeat step 3.
Observe that again, after 2 seconds an os.clock() diff is printed with a value near 2.
Set studio’s framerate to 12 FPS. Repeat step 3.
Observe that this time, the os.clock() diff is printed with a value near 3.
Interestingly, if you switch the Stepped out for RenderStepped, the provided DeltaTime parameter does not suffer from this inaccuracy at low framerates.
id assume its because “The Stepped event (equivalent to PreSimulation) fires every frame, prior to the physics simulation.”
while the RenderStepped event runs right before a frame is rendered.
You can see that RenderStepped is just before everything basically so its deltatime should always be stable.
as for Stepped, its in the middle of everything, so thats probably why its deltatime varies, im not an expert though so i could just be spreading bs.
instead of using runservice, you can try experimenting with tick() to create frame-independent loops.
So, do the people replying to this thread not understand how frames work or something? Or do they not understand that the sum of the delta times of frames rendered over any two second period should be… two?
If you’d read the bug report you would know the issue isn’t with deltatimes fluctuating, it’s with the reported deltatimes being inaccurate. Regardless of framerate, the sum of the deltatimes between n frames in a 2 second period should be… ~2 seconds.
Are you using a plugin to cap your framerate, or am I just looking at the wrong place in settings?
Anyway, from my understanding, Stepped reports the amount of physics time elapsed per frame rather than the actual time duration (which is what RenderStepped reports and it’s why the problem is less prevalent there).
What you’re seeing would suggest that the engine is actually running more physics steps per second at lower framerates than it would at normal framerates, which should show up in the microprofiler. While it’s still certainly a bug, it might also confirm some hunches I’ve had…
I’ve done several tests, and I haven’t seen this occurring. I’ve printed output every time a RunService event fires, and they’ve always fired sequentially together. There were no instances of PostSimulation or Heartbeat being printed on their own. I also checked the microprofiler and did not see anything.
I’ve done some further testing. If you sum up the total deltatimes for Stepped, Heartbeat and RenderStepped for two seconds the Stepped sum ends up being over a full second behind at low framerates: