Client side prediction in a networked top-down game

Moderator
Posts: 452
Joined: 2008.04
Post: #1
Hello folks,
I'm working on adding some client side prediction to my networked game (My udg contest entry, Reclaimed). However, server side corrects of the players position tend to 'fight' with the player's movement and they tend to be out of sync by quite a bit, sometimes causing the player to lerp 1/3rd of the way across the screen.

The initial problem I'm solving is one of the main complaints people had with Reclaimed in the udg contest: it felt very jumpy. When you push a key, the client send "I want to move east" to the server, and then the server sends back your new position, if there wasn't anything in the way of the move. The disadvantage here is that it takes the time for a round trip message before you see the result of your keypress, often 100-150 ms. It has the advantage of being easy to code under a deadline, because the client can be very dumb: It doesn't need to know where you can't walk. It also easily keeps the server as the master arbiter of the correct gamestate and position of everything.

So, my basic approach was to track the most recent position that the server sent, and also to track the current position of the player (which the client can change). I also track how old that position from the server is, so I can tell how out of date it is.

So, every frame, I linearly interpolate (lerp) between the currently believed position (which changes on the client side as you move around, without communication to the server) and the last known correct position from the server. So, if you're walking around, and the client side prediction is incorrect, the server will be periodically sending your correct location, and the hope is that you would snap back to where you belong, hopefully before you got too far away from that point.

This doesn't work out great, I made a movie of me walking around with 400 ms latency:
http://kortham.net/temp/reclaimedPrediction.mov

I'm struggling with when and how to lerp the player's position. It seems like when you are moving, the lerping does not happen, but only when you stop. Maybe the amount of lerping that happens should be dependent on the age of the data from the server. I'm not really quite sure how it gets so far off when you're walking in a straight unobstructed line.

I've tried to base my strategy after this:
http://developer.valvesoftware.com/wiki/...erpolation
(among others, but this directly address the interpolation issue)

Any suggestions on how I can handle this are appreciated!

Howling Moon Software - CrayonBall for Mac and iPhone, Contract Game Dev Work
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  P2P or Client/Server? TokyoDan 2 4,658 Aug 3, 2009 06:15 AM
Last Post: georgiph
  how does bind() work in relation to a client. BinarySpike 3 4,164 Aug 23, 2006 02:44 PM
Last Post: OneSadCookie
  Subversion Client BeyondCloister 8 4,147 Jun 7, 2006 01:04 PM
Last Post: ravuya
  Need help porting an MMORPG client Radu 62 28,713 Mar 31, 2006 11:47 AM
Last Post: igame3d
  host-client matchmaking "server"... dave05 3 4,307 Sep 15, 2005 04:03 PM
Last Post: Steven