When is lag compensation needed?

Recommended Posts

So I have been spending some time learning about the basic concepts of online multiplayer programming. One that I have been recently thinking about is "lag compensation". I think this process goes by several different names, so I will explain what I mean so we are all on the same page. What I am referring to is the process of "rewinding" the server state to an earlier time to see if a bullet connected, a ball was hit, etc., taking into account what the player was actually seeing when they pressed the button considering things like "lerp" time, etc. 

My understanding is that this began as a solution to the problem of many headshots or other pixel-perfect collision detections missing due to latency and delay on entity movements for each client. So my question is, when do you need to actually do this type of lag compensation? Is it a requirement for almost all games to feel like they are playing correctly? Are games that don't specifically require pixel-perfect collisions such as Diablo III or World of Warcraft performing a step such as this? If a game like Zelda: A Link to the Past on the Super Nintendo had online multiplayer, would you imagine it would need to have lag compensation? It doesn't feel to me like 50 - 200ms would have a major impact on a game such as that in most circumstances, but I am not sure if I am missing something. 

Thank you! 

Share this post


Link to post
Share on other sites

Like Kylotan said, it depends on how fast entities move relative to the latency. It should be easy to calculate the effects in most cases and state rewinding is not the only way to compensate for lag. For example, if entities generally move at a speed of 5m/s and you'd like to compensate for 200 ms of latency, you could extend the range of a fireball spell by 1m. You could extend the range both client and server side, or just server side. There are up and down sides to either approach. If you only extend the range server side, the client's input is less likely to rejected by the server, but you open yourself up to cheating to get that little bit of extra range. If you extend it on both sides the server will not reject as much for the range it was actually designed for, but you'll be more likely to be run into situations where you're client is within maximum range but the server rejects the input.

There are a lot of ways to go about it and the correct solution depends on the type of game and what you value most.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now