`DeltaTime` is extremely inaccurate / unreliable at lower framerates

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:

  1. Open the repro place file attached to this bug report
  2. Run a playsolo session at 144 FPS.
  3. Hold the LeftShift key. Observe that after 2 seconds, a os.clock() diff is printed and it has a value near 2.
  4. Set studio’s framerate to 20 FPS. Repeat step 3.
  5. Observe that again, after 2 seconds an os.clock() diff is printed with a value near 2.
  6. Set studio’s framerate to 12 FPS. Repeat step 3.
  7. Observe that this time, the os.clock() diff is printed with a value near 3.

Bug repro:
DT_BugRepro.rbxl (54.4 KB)

Expected behavior

It is expected that DeltaTime would accurately reflect the time between frames

8 Likes

Interestingly, if you switch the Stepped out for RenderStepped, the provided DeltaTime parameter does not suffer from this inaccuracy at low framerates.

2 Likes

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.

image
Reference

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.

hope my mumbo jumbo was atleast a bit useful.

2 Likes

ive also read that physics get throttled at low frames so that might be the cause of your issue somehow.

1 Like

I was thinking the same. In my eyes, this post would be better off as a feature request of some sort, as it seems that Stepped is working as intended

1 Like

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?

4 Likes

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.

2 Likes

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…

1 Like

Can use any method. Live game client’s FPS setting, studio plugin, or an FPS unlocker program.

The docs don’t state that as being the case, they state that the provided deltatime is the amount of time that has elapsed since the last frame:

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:
image

Repro:
DT_BugRepro2.rbxl (54.3 KB)

3 Likes