Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
2

Time.deltaTime for Roblox Lua?

Asked by
Exsius 162
10 years ago

Does anyone have a wiki link for the function if it even exists

http://docs.unity3d.com/ScriptReference/Time-deltaTime.html

1 answer

Log in to vote
2
Answered by
adark 5487 Badge of Merit Moderation Voter Community Moderator
10 years ago
Edited 8 years ago

While you can only calculate the per-renderframe delta time on the Client (because only LocalScripts can use RenderStepped), you can implement delta time using tick():

01local last = tick()
02while true do
03    local t = tick()
04    local dt = t - last
05    last = t
06 
07    print(tick)
08    print(dt)
09 
10    wait() --waits 1/30th of a second, usually.
11    --game:GetService("RunService").RenderStepped:wait() --waits the exact amount of time it takes to create the next frame. Maxes at 1/60th of a second.
12end

EDIT: For future explorers:

game:GetService("RunService").Heartbeat:wait() updates with the physics handling on the Server, which is slightly faster than what wait() on its own will give you.

0
Thanks a lot :) Exsius 162 — 10y
Ad

Answer this question