"The version I have uploaded to http://tank.rjdlee.com does not currently have server interpolation, but I have implemented it in the current code.
When I was programming the initial version of multiplayer Tanks, I forgot about the effects of latency on gameplay and only saw the effects manifest on the live version.
There are a number of resources on this subject, but those don't make it too much easier to implement.
- https://developer.valvesoftware.com/wiki/Source_Multiplayer_Networking
- http://gafferongames.com/networked-physics/snapshots-and-interpolation/
- http://www.gabrielgambetta.com/fpm3.html
I followed the methods above and implemented a snapshot system on the server. It produces compressed versions of my game's map and all its entities at set intervals. Then, I created code to load past snapshots of my game and replay changes on top of those.
An issue I noticed with my current code is when I rewind my game to a past snapshot, I can't take snapshots of it (otherwise I'd be snapshotting old states). This can lock up the game for a long time. The solution to this would be to have a map specifically for replaying old versions running in parallel to the actual map. It may be a bit difficult to converge the replaying map into the actual map, though.
The snapshot system also allowed me to produce a list of changes between two snapshots, which I could send to clients periodically to update them with information about the game's current state.
I hope you enjoyed my short series on game development, once again, I apologize for the brevity of it.
Comments