Advertisement Jump to content

When is lag compensation needed?

This topic is 484 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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

  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!