Archived

This topic is now archived and is closed to further replies.

Brandisco

Client lag correction

Recommended Posts

Okay here is what I have so far in my online RPG. The clients send their XY coordinates to the server every 500ms and the server sends all of the clients XY coordinates to all of the players (I left out the optimizations I am using -- like client doesn''t send every 500ms if he hasn''t moved) As you can probably see this causes lag on the clients computers because slowly the other players on your map get farther from where they actually are. When you get another players coordinates I have it walk towards those coordinates from wherever its currently at. This is on a timer and the other players walk the same speed as you do. I need to fix this to improve the true accuracy of other players. I have come up with several possibilities and am asking for other possibilities and which one would be the best. Of course in theory if the client and server updated every 0 ms then everything would be fine. I could make the ''other players'' walk faster than you do that way they could always be kept up to where there supposed to be. So client A walks at 5 on his machine but on everyone elses machine he looks like he is walking at 10. I could get rid of walking and have players always warp on the updates to exactly where they are supposed to be. (loosing animation) Instead of sending XY coordinates I could send a vector and just let all the clients continue moving the player in that direction until the player stops moving. I dont know how much this would help though? Maybe if I slightly increase the other players speeds so its hardly noticeable and increase the amount time of client and server ( maybe 100,500ms respectively). Anxiously waiting for your input. Thanks

Share this post


Link to post
Share on other sites
500ms is a long time (half a second) to have between position updates. Rather than send info for all players just send the info about those that can have an impact on the player. i.e. those that are visible, audible or interacting. Also send out the information more frequently. A lot of games update 15-30 times a second with general position information and for any special events that occur (movement/interaction) a message should be sent off straight away to inform others of the change.

I''m not to sure about how your implementing the game but there are some good dead-reckoning algo''s out there. I particularly like using Cubic-Splines (gives a nice smooth realistic feel). More info can be found in this GameDev article.

http://www.gamedev.net/reference/articles/article914.asp

You could use some time-dilation type effects (other people moving slightly faster to regain position) to combat the lag and as you mention your dev''ing an RPG so does the true player position matter as long as it causes no graphical glitches and the player is within a tolerable limit?

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
For RPGs i suggest switching to a pure event base network scheme. Dont sent raw position data ex.(x,y,speed,dir,accel etc..) rather send timming and event data ex.(time, goto[x,y]).

Upon reception of the event, calcuate how much time has passed from the gloablly sycnrhonized timmer (use NTP). From that you can confidently place the entity and let the pathfinding handle itself. In theroy if the game states of your clients are synchronized enough this would be good enough for the entity to arrive around the same time on everyones machine, unless the distance travel time is smaller than the lag of the client.

Good Luck

-ddn

Share this post


Link to post
Share on other sites