Versy
I’ve been thinking more about your code, and I suspect the slow motion you’re experiencing might be caused both by your implementation and potentially by your machine.
When you calculate Step
like this:
Step = Accumulate - FMath::Fmod(Accumulate, ActualFPS);
If, for any reason, Accumulate
exceeds twice the ActualFPS
, you’re only advancing your timeline by one step, when in fact you should be advancing it by two steps.
I also remembered we have a Unity example that does something similar here. I adapted the logic to C#:
float Step = DeltaTime;
if (bDisableInterpolation)
{
Accumulate += DeltaTime;
const float FrameDeltaTime = 1.0f / DiscreteFPS;
constexpr int32 MaxFrameSkip = 5;
int32 FramesToSimulate = 0;
while (Accumulate >= FrameDeltaTime)
{
FramesToSimulate++;
if (FramesToSimulate > MaxFrameSkip)
break;
Accumulate -= FrameDeltaTime;
}
if (FramesToSimulate == 0)
return;
Step = FramesToSimulate * FrameDeltaTime;
}
The MaxFrameSkip
should prevent steps from getting too large.
Let me know if this version works better.