Sponsored By

The war on lag starts with latency

We explore what latency is and why it’s so important in making sure that your multiplayer matches are fair.

Andrew Walker

October 10, 2023

4 Min Read

You load up your favourite game, ready to splat some aliens or hide in a cupboard for thirty minutes, only to find that your player keeps mysteriously teleporting around the map. One moment you’re stuck in a wall, the next you’re hovering fifty feet over a chasm. You try to blast the enemies charging towards you, but your bullets seem to only strike air.

Sadly, these aren’t magical abilities. It’s lag. And it can ruin the gameplay and experience for the player. Bullets don’t register. Characters keep jittering all over the place. And your players get more and more frustrated.

The culprit? Lag. More specifically, bad latency. But what exactly is latency? Why does it matter so much? And what can you do to improve it?

What is latency?

If you’re going to understand latency – and why it matters – you also need to understand bandwidth.

  • Latency measures time. It’s how long a packet of data takes to move from one computer to another – measured in milliseconds. So the higher the number, the longer it’s taking.

  • Bandwidth measures size. It’s how much data you can stuff into a single moment. The higher the number, the more data you’re getting at once.

It’s like a pipe. Bandwidth is the width of the pipe – how much water it can actually hold. Latency is how fast the water is moving through the pipe.

Usually, when you’re surfing the web or downloading a particularly big file, the latency isn’t all that important. If you can receive 100 megabits a second – the bandwidth – it doesn’t really matter if each packet is taking 1 millisecond or 100. You won’t notice the difference.

In extreme cases, bandwidth matters way more than latency. For example, if you need to transfer an absolutely massive amount of data. If you literally grab a hard-drive and just walk to your neighbour and plug it into their computer, that’d be much faster. It’d have really high bandwidth, but also really high (slow) latency. (Fun fact, this is called sneakernet.)

But in a multiplayer game, you’re not sending huge files. You’re sending lots of little ones. So those milliseconds matter. You need low latency.

Low-latency leads to fairer games

When everyone is on a level playing field, nobody gets an advantage. Imagine you have two players in a match: Alice and Bob. Alice has way more latency than Bob. If they round the corner and shoot at each other, Alice is:

  1. Going to see Bob before Bob sees her (giving her a chance to react first)

  2. Alice’s shot is going to register before Bob’s

There are ways to avoid this problem. You could register the hit on the player’s side, rather than on the server. But that can lead to poor Alice getting shot, even though on her screen she’s already ducked back behind cover. Not ideal.

When your players have roughly equal latency, then neither player gets an unfair advantage.

But why do some players get really bad latency?

Physical distance matters

So why might Alice have really low latency, while Bob has really high latency? Well, it usually comes down to literally how far away from the server they are. Light is fast, but it’s not magic. It still takes time. And the Earth is massive. It takes light about 40 milliseconds to go from North America to Africa. Which means that’s the absolute best latency you could possibly get.

Though, that’s not the full story. The route the data takes matters, too. It’s like when you’re planning a roadtrip. One route might take you on fast roads and pretty much as the crow flies. But another might be in the middle of nowhere and have to travel down dirt roads, twisting and turning. Likewise, if your data takes a direct route it’s simply going to be faster.

Their local network could be rubbish

The type of network matters, too. If they’re using a public wifi – with a hundred other people clogging up the airwaves – it’s going to take a while for their data to get through.

Much like our example about planning a route, it also matters how much traffic is on each road. Even if you’re taking a direct path, you might get slowed down by everyone else.

This often happens on a player’s local network. They have other people in the house, hogging the line, and generally slowing everything down. And it’s an area that you can’t control.

Add latency to your matchmaker

Making sure that your game runs as smoothly and fairly as possible means trying to bring that latency down.

If you want your game to be really efficient, we recommend adding a way to check for the player’s latency as part of the matchmaking process. Add in a check and only pair players if they’re within a certain threshold of each other.

Read more about:

Blogs
Daily news, dev blogs, and stories from Game Developer straight to your inbox

You May Also Like