Separating server and client responsibilities
Now that we have players sharing the same world, we need to establish which actions they are responsible for and which actions are part of the server’s responsibility. For instance, if a player shoots on their game instance and their bullet damages an asteroid but this asteroid was already destroyed by another player, what should happen? For this kind of situation, the server is the perfect mediator to prevent instance conflicts.
With all this context in place, players tell all peers, including the server, to update their Player
instance according to their actions, but only the server should have the authority to manage the actual impact of these actions in the game world, such as if the player managed to destroy an asteroid or not. In the next section, we are going to understand how players can sync their actions, not only their objects’ properties, across all network-connected peers.