Techniques in multiplayer synchronization

I’m finding myself doing a lot of synchronization in the game mode. First I wait for the players to receive their states, and they report to the gamemode when done. Then I wait for them to spawn their pawns, and those report to the gamemode when done. Then I wait for them to finish loading the world, and they report to the gamemode when done. Then I wait for them to spawn the dynamic actors together, and they report to the gamemode when done.

Point being: I’m doing a lot of “report to the gamemode when done” and the gamemode is keeping a lot of lists of “these players have pawns, these players have the world loaded,” etc. When all the lists are full we start the game.

My other approach is to have each player run a state machine and to keep track of the lowest state any player is at, then I can advance the game when all players reach the same state.

Is there a more elegant solution to this that people are using? What kinds of patterns are people using to get the peers all on the same page?

I haven’t done a lot of work myself on these kinds of solutions. But I recently watched a talk from ProjectRed folk who used a lot of jobs for basically everything. Their intent was different, but I think something like that could make your logic simpler to go through and more generic.

Basically, all these steps could be jobs in a queue, that way when the previous one ends, the next one can automatically begin, without having counters, ifs and all that logic multiple times over. Now, if you want to fully avoid waiting, you may need into when you absolutely must wait and when you can avoid it. But I think queued jobs would be simpler to track if you still want to keep this step-by-step process.

This is a good place to start, thanks!

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.