Get the elapsed game time
You can multiply the current frame number minus the RollbackWindow with the the delta time of a tick.
C#
namespace Quantum {
unsafe partial class Frame {
public FP ElapsedTime {
get {
return DeltaTime * (Number - SessionConfig.RollbackWindow);
}
}
}
}
The better approach would be to track the elapsed time yourself each tick. This is required when you change DeltaTime during runtime or want to suspend a running game to pick up later.
C#
// add a global variable to your qtn-file
global {
FP ElapsedTime;
}
// create a system
public unsafe class TimeSystem : SystemBase {
public override void Update(Frame f) {
f.Global->ElapsedTime += f.DeltaTime;
}
}
Caveat: Counting like this can eventually lead to inaccuracy because of the precision of the FP. Count only the elapsed ticks (as an Int32) to improve that.
Back to top