I've recently attempted to develop a simple client prediction for an FPS based on Gaffer on Games famous blog (http://gafferongames.com/game-physics/networked-physics/).

Now I've gotten to the point that everything works (more or less), my main problem is crossing the message sent from the server and finding the appropriate snapshot on the client. I can use the last/average ping time to find a very near state, but it will never be exactly timed/placed as on the server.

So my question is - how exactly can I sync and find the time stamp sent from the server to the client and find which snapshot is the correct one on the client?


1 Answer 1


Just read this: http://www.gabrielgambetta.com/?p=22

  1. On every recording record current time/frame
  2. On every RPC sent to server attach frame/time
  3. Server sends back result with frame/time
  4. Now the client knows exactly which frame the server's result is about
  5. Commence "player prediction" + rewind & replay
  • 3
    \$\begingroup\$ I am gabrielgambetta and I approve this message ;) Did you find anything unclear? \$\endgroup\$
    – ggambetta
    Jul 30, 2013 at 16:13
  • \$\begingroup\$ @ggambett - after reading Gaffer's blog + Valve + QRA docs (which have some things unclear there) your blog post filled in the missing pieces I needed to finish it, now it works perfectly. Thanks for a great blog post. \$\endgroup\$
    – Ron
    Jul 31, 2013 at 11:34
  • \$\begingroup\$ One small thing that I'm not quite sure about (and working on now) is synchronizing stuff like gun fire in an FPS \$\endgroup\$
    – Ron
    Jul 31, 2013 at 11:41
  • \$\begingroup\$ The new 4th article (gabrielgambetta.com/fpm4.html) in my series explains how to make gunfire "precise". Beyond that, as usual just "predict" on the client (show blood or whatever) and obey the server. \$\endgroup\$
    – ggambetta
    Jul 31, 2013 at 12:36
  • 1
    \$\begingroup\$ @ggambett - Yeah I read it, great stuff (Valve's lag compensation) - but what I meant is how to add stuff like remaining ammo/player reloading with player prediction (and correction). e.g. player shoots and begins to reload, packet loss caused a firing frame to get lost, player receives that he has 1 ammo while reload animation plays. \$\endgroup\$
    – Ron
    Jul 31, 2013 at 12:51

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .