Hi !
Featured games (91)
games approved by the League of Dukes
Games in Showcase (808)
Games in Android Showcase (239)
games submitted by our members
Games in WIP (872)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Lag Compensation  (Read 16699 times)
0 Members and 1 Guest are viewing this topic.
Offline cubemaster21
« Posted 2016-01-23 20:49:15 »

I've been working on a little multiplayer game based on Valve's Source Multiplayer method (Described here: and I'm coming across an issue which someone asks on the page, but no answer is presented. I was wondering if anyone here could help me answer it. The question is as such:

From the page: After 100 milliseconds, the client will receive the server snapshot that contains the changes based on the user command he predicted earlier.
After 50 milliseconds, though, the client will receive a server snapshot that does not yet contain the changes based on the user command. Does the client simply ignore this snapshot? If so, what are the rules governing this?

In my case, this causes a stuttering when players let go of a movement key. Any help? I can provide some code if necessary, however, I think this is more of a conceptual issue than code issue.

Check out my game, Viking Supermarket Smash
Offline theagentd
« Reply #1 - Posted 2016-01-23 21:16:14 »

If you try to predict the movement of objects you get the problems you worry about. It's fairly easy to assume that objects will continue at the same speed, but this causes big problems when there are sudden changes. If you have a player standing still and then suddenly start moving, the message that s/he started moving will be delayed meaning that when the other players receive this message he'll suddenly snap to his predicted position. The same problem happens when the player stops, at which point the extrapolated player will suddenly teleport back to where he stopped.

Valve don't extrapolate positions. You will be displaying a delayed version of the world if you use interpolation, which is the standard nowadays. In this case you simply try to make sure that the world (other players, physical objects, etc) look smooth by interpolating between the state you get to reduce stuttering. All objects will be delayed by the ping, but at least they're 100% smooth. I believe I read somewhere that the Battlefield games use interpolation for twitchy character movement, but extrapolation when dealing with vehicles because they simply can't change their speed quickly and mostly just continue in the same direction they're going.

However, each client is a bit flexible when it comes to their own players. When you move in the source engine the game sends a movement command to the server, but the game moves your character immediately without waiting for a response. As long as the player isn't too far away from the last confirmed position from the server, the client is allowed to move things before getting confirmation. So the client doesn't ignore the server when it says where the player is, but it doesn't enforce it completely to reduce perceived lag. If you've ever heard of "rubberbanding", it happens when the client and the server disagrees and the player is suddenly snapped or slowly pulled to his correct position. Most games are simple enough that this never happens unless your ping is fluctuating a lot.

Pages: [1]
  ignore  |  Print  

mercenarius (13 views)
2020-06-04 19:26:01

mercenarius (21 views)
2020-06-04 19:13:43

Riven (865 views)
2019-09-04 15:33:17

hadezbladez (5847 views)
2018-11-16 13:46:03

hadezbladez (2656 views)
2018-11-16 13:41:33

hadezbladez (6272 views)
2018-11-16 13:35:35

hadezbladez (1517 views)
2018-11-16 13:32:03

EgonOlsen (4748 views)
2018-06-10 19:43:48

EgonOlsen (5803 views)
2018-06-10 19:43:44

EgonOlsen (3297 views)
2018-06-10 19:43:20
A NON-ideal modular configuration for Eclipse with JavaFX
by philfrei
2019-12-19 19:35:12

Java Gaming Resources
by philfrei
2019-05-14 16:15:13

Deployment and Packaging
by philfrei
2019-05-08 15:15:36

Deployment and Packaging
by philfrei
2019-05-08 15:13:34

Deployment and Packaging
by philfrei
2019-02-17 20:25:53

Deployment and Packaging
by mudlee
2018-08-22 18:09:50

Java Gaming Resources
by gouessej
2018-08-22 08:19:41

Deployment and Packaging
by gouessej
2018-08-22 08:04:08 is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!