Using the timeline with a track that goes from 0 - 1
would be a good delta for a lerp. And a better solution.
Also, you don’t have to store Delta Seconds, you should instead use Get World Delta Seconds
for gameplay mechanics. This will scale based on world time scale.
What is Get World Delta Seconds
Explanation of tick delta time.
Delta time is the fraction of sections that have passed by since the last tick.
When you multiply distance by delta time on tick, you’re making that calculation independent of frame rate.
For instance:
-
1
frame per second: delta time will be the float value of1
-
60
frames per second: delta time will be0.0166666
-
128
frames per second: delta time will be0.0078125
Over the course of 2
seconds move an object 5 meters. so you want it to move 5 / 2
meters per second = 2.5
meters per second.
So multiply delta by your speed Delta Time ( DT
)
The following is the distance the object will travel in the first second:
distance traveled will be =
frames called
*
DT
*
Speed
-
1 frame per second, the tick will be called once.
final distance =
1 * 1 * 2.5
=>2.5
meters -
60 Frames per second, the tick will be called 60 times.
final distance =
60 * 0.0166666 * 2.5
=>2.5
meters -
128 frames per second, the tick will be called 128 times.
final distance =
128 * 0.0078125 * 2.5
=>2.5
meters
The Delta Time changes every tick to account for how long it has been since the last tick, so you don’t have to rely on a steady framerate.