We keep reusing the DeltaTime from the last move, but that only works if our own DeltaTime more or less matches that of the pawn’s owner, doesn’t it? If our framerate is twice that of the owner, we’ll be re-applying the move twice as fast as we should, and the car will move twice as fast.
I think a more accurate solution would be:
void AGoKart::Tick(float DeltaTime)
{
...
if (GetLocalRole() == ENetRole::ROLE_SimulatedProxy)
{
FGoKartMove Move = ServerState.LastMove;
if (Move.Time != 0)
{
ServerState.LastMove.Time = 0;
Move.DeltaTime = GetWorld()->GetGameState()->GetServerWorldTimeSeconds() - Move.Time ;
}
else
{
Move.DeltaTime = DeltaTime;
}
}
}
where I use the DeltaTime
since the server got the state for the first tick after receiving the update (move.time != 0
) and the simulated proxy’s DeltaTime
afterwards until the next update.