Get DeltaTime
<#
A general purpose way to determine the time lapsed since a function
or method was last called. Useful for loops where you want to lerp
over time or to have cooldowns on abilities or interactions.
#>
var PreviousTime : float = 0.0 #add this outside of GetDeltaTime to retain the value between calls
GetDeltaTime() : float =
var DeltaTime : float = 0.0
# ensures that first call will return a zero as no prior time exists
if (PreviousTime = 0.0):
set PreviousTime = GetSimulationElapsedTime()
return DeltaTime
# returns the time lapsed since the last call
else:
CurrentTime := GetSimulationElapsedTime()
set DeltaTime = CurrentTime - PreviousTime
set PreviousTime = CurrentTime
return DeltaTime
<#
Follow @kryyative on Instagram Threads for more useful Snippets, UEFN news,
tutorials and community spotlights!
#>