Hi all, I’m building a multiplayer game with my own server.
The server is sending the events that happened in the game to all the clients.
The event contains details about what happened and when.
My problem is if 1 client loses connection for a few seconds he will relog and get all the “past” event,
now I need somehow to execute those events in the past so that his game status will be the same as the status of other clients.
Any ideas how to accomplish that?
Thanks in advance
Resync full state on relogin and ignore prior events.
Was thinking about it, but the server works in a deterministic way so there is no “full state” only a list of events so that all clients interpret the events in the same way
Store last (x) events (on the client as well) and rollback to the disconnected state based on the timestamps.
Apply missed states and then apply player changes. (Fast-forward)
When u say “apply” should I just use the update method to check if the current timestamp is the same as the event timestamp and than execute it?
or is there another way?
You can use anything, but probably something like Lerp will work best to transition between states over certain duration.
When disconnect occurs you can decrease the actual duration of the states played and as a result fast-forward to the point where client should be.
So the timeline would look like this:
A------>Bx-----x------C------x------D------Reconnect->B->C->D->–>E------->F