dark mode light mode Search Menu
Search

How do Multiplayer Games Really Work?

Sherif Salama on Flickr

If you’re an avid gamer, there’s a good chance you’ve played an online game before. These games connect you with players all around the world in one game, so you can play with (or against!) one another. Have you ever wondered how they work? What’s going on in the background that allows your game to see the inputs of a player halfway around the globe from you?

In order for multiplayer games to fully work, there needs to be a ‘central hub’ which every player’s game reports to and receives reports from. Sometimes a game may select a specific player to be the host of the game; this is called a ‘peer-to-peer’ service. Most of the time, however, the developers of the game will provide a central server which all players connect to.

The server is where all the action takes place. You can imagine the game being played inside the server itself, if it helps! When you take an action in the game, it sends a message to the server saying what you did, and the server tells your game what happens next. As such, the main game isn’t happening on your PC; it’s happening on the server, and your game is simply a window through which you can watch and interact with the game.

Let’s look at an example. Let’s say you’re playing an online fantasy game and you cast a fireball at a zombie. Your game has to tell the server ‘my player has decided to throw a fireball at a zombie’. The server listens to this, plays it out in the game that it’s running, then sends back a message saying ‘you managed to defeat the zombie’. Your game hears this and displays the zombie’s defeat on your side.

Of course, the amount of communication between your game and the server varies depending on the kind of game being played. If you’re playing chess with someone online, then the game lets the server know where you moved your piece, and the server lets you know where your opponent moved theirs.

When you look at Fortnite, however, there’s a lot more data to tell everyone; custom clothes and animations, the weapon each player is holding, where they’re looking, what they’ve built, and whether or not they’re on the move, to name but a few. This takes a lot of work to provide a smooth game experience!

As you can see, there’s a lot of back-and-forth between your game and the server. Your game is telling the server what you’re doing, and the server is telling your game what’s happening in the world. This is all well and good, but problems start to arise when the communications get spotty. If the server is a long way away, it takes longer for the messages to reach the other side, which causes the game to feel ‘laggy’. If you ever see a server with a ‘ping’ number, this number is the amount of milliseconds it takes to talk to the server. The lower the number, the less lag there is!

Servers also have to be vigilant to uphold the game’s rules. If the server simply accepted any message from a player, then a mischievous hacker can tell the server ridiculous things like ‘my character is always full health’, or ‘my character defeats everyone on the server’. To stop this, servers need to match up what the players are saying with the game’s rules. If they spot someone trying to cheat, they can disconnect them to stop them from ruining other’s fun!

A lot of work goes into making these client-server connections run smoothly so that players can enjoy their game without issues. The next time you’re playing an online game, try to think about that.

Learn More

About Game Servers

https://en.wikipedia.org/wiki/Game_server

Client-Server Networks vs Peer-to-Peer Networks

https://www.techrepublic.com/article/understanding-the-differences-between-client-server-and-peer-to-peer-networks/

What Gamers Need To Know About Network Synchronization In Games

https://www.makeuseof.com/tag/gamers-network-synchronization-games/