How do online video games work?

57 viewsOtherTechnology

I know how building a solo game works, with models and interactions coded, but how are games made so that those interactions happen on many players screens with just tens of milliseconds of difference. Is it code or is it putting your game files (models + code + whatever else I am missing) on a server that can be accesed by peoples devices?

In: Technology

7 Answers

Anonymous 0 Comments

There is almost always one master copy of the game running on a server somewhere (or on player 1’s computer). That master copy will connect to all the players (clients) and ask what they want to do. At that point, it’s not that different from a local multiplayer game: player inputs command, master copy knows what that command does to the character they are in charge of, and everyone’s positions are updated. The main difference is that the master copy then tells the clients what it thinks the field looks like and their versions of the game are expected to check to make sure the world looks right.

Sometimes the clients think they did a thing, but the master copy believes otherwise (Player 2: I totally made that jump! Player 1: no I was dismantling the bridge at that time and you fell) and that can cause players to “rubberband” into the “correct” position when the clients have to correct themselves.

Games also can get clever with fixing discrepancies. I was watching a video a few years ago where a certain game had special logic for when a sniper believes they got a kill, but a defender dodged at the last second on their end. The game decides the sniper had the more accurate representation of how well their shot was aimed and gives them the kill, but it then plays a special death animation for the shot player to let them know their juke almost worked, but they didn’t start in time.

You are viewing 1 out of 7 answers, click here to view all answers.