RunService.Stepped giving incorrect deltaTime

Recently I noticed some issues with some code and after some testing I found out something weird. For some reason when i print out RunService.Stepped’s deltaTime it shows me the time in seconds since the function was initially connected, instead of the time between frames

Code:

game:GetService("RunService").Stepped:Connect(function(dt)
	print(dt)
end)

Output after one minute:
steppedDelta

If you try to do the same with Heartbeat and RenderStepped, the values do correctly show the deltaTime. weirder yet, if you try getting the deltaTime using the tick() method in a Stepped function you also get correct values.

code:

deltaTime = 0
lastTick = 0

game:GetService("RunService").Stepped:Connect(function()
	deltaTime = tick() - lastTick
	print(deltaTime)
	lastTick = tick()
end)

Output after one minute (stayed the same since the start):
image_2023-07-18_000224780

Is this intentional behavior? Am i overlooking something or is this not supposed to happen?

1 Like

This is indeed intentional, as the first parameter is time, the second is delta.

oh thats makes sense now, damn i feel stupid. This caused me a lot of trouble for a couple of days now.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.