Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Geek Culture / Interesting read for defeating lag in multiplayer games

Author
Message
FireIndy
18
Years of Service
User Offline
Joined: 17th Jan 2007
Location: US of A
Posted: 7th Aug 2012 05:29
Hey guys,

I'm working on a multiplayer game and found this article that may be useful to some people.

http://www.gamedev.net/page/resources/_/technical/multiplayer-and-network-programming/defeating-lag-with-cubic-splines-r914

It's about a Dead Reckoning algorithm using cubic splines to help reduce the jitter in player movement. I'm personally going to attempt to implement this and hope that I do it right. But it's a good read none the less.

Benjamin
22
Years of Service
User Offline
Joined: 24th Nov 2002
Location: France
Posted: 7th Aug 2012 05:46 Edited at: 7th Aug 2012 05:47
That's one part of the solution, but there's more to it:

https://developer.valvesoftware.com/wiki/Source_Multiplayer_Networking



Support a charitable indie game project!
FireIndy
18
Years of Service
User Offline
Joined: 17th Jan 2007
Location: US of A
Posted: 7th Aug 2012 05:49
Quote: "That's one part of the solution, but there's more to it:

https://developer.valvesoftware.com/wiki/Source_Multiplayer_Networking"


Yeah, I've been trying to follow that article to an extent. Gotta love the Source Engine.

Phaelax
DBPro Master
22
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 7th Aug 2012 06:19
Back in college, I wrote my final networking paper on this subject. I wonder if I still have it somewhere.

"You're not going crazy. You're going sane in a crazy world!" ~Tick
TheComet
17
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 7th Aug 2012 10:58
RTS games use a technique called "lockstepping".

http://gafferongames.com/networking-for-game-programmers/what-every-programmer-needs-to-know-about-game-networking/

TheComet

Your mod has been erased by a signature, please reduce him [overall] to no larger than 120 kg please.
Diggsey
19
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 7th Aug 2012 22:28 Edited at: 7th Aug 2012 22:28
That first article seems to assume that you know both the start and destination positions of the entity, but usually you would only know the starting position, as the player will already have moved past the most recent position received from the server.

For a networking engine I've been working on I'm predicting ahead using linear interpolation to get an estimate for where the player will be, and then using the information received from the server to calculate a correction value, so if I receive an update from the server which was the position 100ms ago, I look at where I had predicted the entity would be at that time and find the difference.

This correction is then applied to the current predicted value over a certain length of time so that the predicted position smoothly adjusts to the actual position.

I also don't bother with the back-in-time hit detection described in the source multiplayer article, since the clients don't lag behind the server as much in my model, and in reality bullets do take a few milliseconds to travel, so it doesn't matter if there is a small delay between the client sending the fire message and the server acting on it.

[b]
FireIndy
18
Years of Service
User Offline
Joined: 17th Jan 2007
Location: US of A
Posted: 8th Aug 2012 08:58
Quote: "For a networking engine I've been working on I'm predicting ahead using linear interpolation to get an estimate for where the player will be, and then using the information received from the server to calculate a correction value, so if I receive an update from the server which was the position 100ms ago, I look at where I had predicted the entity would be at that time and find the difference."


So, just to clarify. On receiving a position packet from the server about the client position on the client side, you calculate a prediction using linear interpolation of where you should be (say in a second, just for kicks), and save that prediction. After you send your position to the server and get it back, then you check the server position against the predicted position and adjust accordingly?

Sorry, I'm just curious. I've got my position sending all wonderful and whatnot. But these optimization techniques are something I really need to include. So the more I can learn, the better. My client sends and X and Y to the server, and then the server sends it to everyone (minus the person who sent it right now). So I definitely need something like this so a)the server has final say over player position (to counter any attempts to alter it before it sends) and b)to help with "jitteryness".

Phaelax
DBPro Master
22
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 9th Aug 2012 03:02
Based on previous positions, when a packet is missed the server guesses where that player might be. FPS games use this a lot. Ever noticed if a player lags out and their character just keeps moving forward instead of remaining stationary?

Once communication is reestablished, either the player can update to match where the server thought you were, thus the player sees jerky movement, or server updates to tell everyone else where you really are and you're movements would appear jerky to everyone else.

"You're not going crazy. You're going sane in a crazy world!" ~Tick
MrValentine
AGK Backer
14
Years of Service
User Offline
Joined: 5th Dec 2010
Playing: FFVII
Posted: 13th Aug 2012 10:07
This is very handy, my only question, how does the server know the direction of the user?

another thing that baffles me is the z axis... why is this always discounted from calculations in everything I ever read about entworking... I do not get it...

Login to post a reply

Server time is: 2025-05-18 15:32:17
Your offset time is: 2025-05-18 15:32:17