EA Lag Compensation Deep Dive
https://www.ea.com/games/apex-legends/news/servers-netcode-developer-deep-dive
(note lag compensation, no-registration, tickrate, etc explained in great detail in the link above for EA blockbuster title Apex Legends)
I am being killed while behind a door/wall, and sometimes I roll back to my previous position (I added BF photo).
This is a spicy topic. It has to do with lag compensation.
In every game since the dawn of online gaming, the main problem for developers to solve is how to fake real time action in something that is not operating in real-time. Essentially, everything you do in online games is delayed because of the latency to the server and back. A lot of things add to this: inputs, rendering, and yes, even server tickrate.
Even worse, on top of all that is your opponent who almost certainly plays with a different level of latency than yours. To solve this, our servers have to constantly look at not only what’s happening for you and your opponent at that moment, but also what was happening from both your perspectives at the time both of you input your actions. Lag compensation is the art of merging slightly different experiences into one shared reality.
There is no perfect solution. There is not one truth. At the end of the day, the server is a sort of time machine. It constantly rolls back the world state to see if your shot hit someone, and then updates the world for everyone accordingly.
To better illustrate this principle, my colleague Earl Hammon wrote a little essay about fairness and lag compensation, and how it all works in Apex Legends. I’m sharing it with you below:
Let's go through various scenarios with two players in Apex Legends called HIGH and LOW. Let's give HIGH a high ping of 300 ms, and LOW a low ping of 50 ms. The difference in their pings is 250 ms.
What happens if they shoot at each other at the same real-world time? Well, LOW's shot will arrive at the server long before HIGH's shot, so LOW has the advantage.
What happens if one of them rounds a corner, so that they can suddenly see each other? Well, LOW has the advantage here as well. LOW is less “into the past,” so they get to see HIGH first. Once again, LOW has the advantage due to their ping. This adds on to the advantage where LOW’s bullets get to the server faster.
These cases are "unfair" in the sense that LOW has an advantage, but they are "fair" in the sense that it's reasonable to expect that the player with lower ping would get the advantage in this situation.
Now, what happens if LOW goes behind a corner to get into cover? Well, HIGH is still in the past when LOW is not covered, so HIGH can shoot LOW before they get into cover, but LOW won't find out about it until HIGH's packets have made it to the server and then to LOW. By this time, LOW sees that they’re safely in cover, yet LOW still got hit. From LOW's perspective, this is a bit of nonsense.
However, this is exactly symmetrical to some of the earlier nonsense that was in LOW's favor! When LOW pops out of cover to attack HIGH, LOW gets to see and shoot HIGH while it appears to HIGH that LOW is still in cover. From HIGH's perspective, this is a bit of nonsense, that they get shot by somebody who was still in cover. This nonsense can’t be eliminated, only transferred between one player or another, because of the simple reality that ping is real and players have different amounts of it.
Some would suggest that it is unfair to LOW that HIGH can shoot them when LOW thinks they are behind cover. The alternative they suggest is that HIGH should have to compensate for their high ping themselves. This would require us to implement an unequal and asymmetrical way of handling latency.
It feels bad to get shot when you think you're behind cover due to bad ping, which is what can happen to LOW. It also feels bad to get shot by somebody before you could even see them due to bad ping, which is what can happen to HIGH. But the nonsense is distributed symmetrically.
We want to be super clear: not all online games work the way Apex does. Some games always give the advantage to players with lower ping, but we actively choose not to with our system. It’s a stance we’ve intentionally taken after looking at the tradeoffs and thinking seriously about fairness in online competition.
To explain our system in simple terms, players with low ping don’t always have an advantage over high-ping players, and sometimes experience nonsense (to us, that’s a technical term).
That’s a tradeoff which is designed intentionally into our system. But the upside is that you can play Apex Legends and play relatively well even if you have higher than average latency, which is really important for rural players, or for players in regions where connectivity is unstable. We believe we should reduce “nonsense” at every opportunity, but when we have to deal with less-than-ideal experiences, we want to do so in a way that’s equal and fair to all players.
This is the reason that almost any time you deal with a bit of nonsense like getting shot while behind a wall or getting hit right as you come around a corner, it’s probably due to unavoidable variation in latency between players and the way our system distributes it. Still, we’re committed to reducing this at every opportunity we get. Not only do we want everyone to have a fair experience, we also want you all to have a fun one.
Thank you for reading!
- Samy (Ricklesauceur) & the Apex Legends team