I have an issue that I need a solution or explanation for.
We have locked our steps on client and server to 33 ms.
We have a client clock that are completely synchronised with the server.
Game loop with lock step:
- Code: Select all
DateTime newTime = DateTime.Now;
frameTime = (newTime - currentTime).TotalMilliseconds;
currentTime = newTime;
if (frameTime > 1000)
{
frameTime = 1000;
}
accumulator += frameTime;
while (accumulator >= PERIOD)
{
ForEachPlayer(delegate(Player player)
{
player.ship.update();
});
tick++;
accumulator -= PERIOD;
syncManager.update(); //send command states
}
An acceleration event is triggered on the client at 100 ms, next tick is nr 4.
The event reaches the server at 132 ms, next tick is nr 4. (32 ms latency)
A stop accelerate event is triggered on the client at 172 ms. next tick is nr 6.
The event reaches the server at 204 ms, next tick is nr 7.
The server has now accelerated 3 steps while the client only accelerated for 2 steps.
How do you make sure both client and server do the same amount of steps?