Demo recording/playback for FPS games

Started by
4 comments, last by oliii 18 years, 10 months ago
Anyone know of any links to resources that possibly explain how demo recording/playback is typically implemented in FPS games? I know most FPS games use a server that has total authority over the clients, and the client sends small structs filled with user commands to the server(what buttons are pressed, the current view angles, sometimes mouse deltas, movement input) It is my assumption that when recording demos the server can simply save these already small bits of data to a file and during playback stream these user input blocks through the normal pipeline to make the game entities do the same things. No doubt there would need to be some sort of timestamp or other synchronization mechanism in each user input struct to keep track of exactly when it the action happened. I assume there would also be bits of data saved to the file that define when and where to create certain entities. There'd be no need to save out effects and such to the file, since they would be re-created automatically as part of the normal simulation process during playback. Possibly in the case of a physics system in the game wouldn't it be necessary to save out impulses to physical objects? If you record a demo where a guy shoots a barell and it rolls down a flight of stairs, I suppose you either have to snapshot the exact origin and direction of all fired weapons, or save out the resulting physical impulse on the barell, so that assuming your physics system is deterministic it should hopefully reproduce the same resulting fall down the stairs. There seems to be alot of black magic involved in a demo recording/playback system. I'm hoping someone can hook me up with some links to articles that give some insight. Thanks in advance.
Advertisement
You are nearly bang on the button. Demo's (and reproducable test cases) are one of the major arguments to make a game engine completely deterministic. If your engine is deterministic, then all you have to do is record the user input and the time at which it occurred and save that out to a file. When you want to play the demo, all you do is simulate the keypresses/mouse clicks of the user. It can actually be very simple when done properly.

It's when the engine is not determistic that you start to have things like dumping the world state and then simulating from then on, perhaps with checkpoints every few seconds to make sure things don't get to wildly out of sync.
You could possibly use in-game movie recording/playing software that will take snapshots every 10 frames or so then compress them to save size and time.
Another way is not to store the user input but rather what the server send to clients :

When recording (during gameplay) :
- send client input to server
- record server messages to file

When playing (during demo-playback) :
- don't send client input
- get messages from the file rather than from the server

Determinism and running at a fixed-time step are the keys to getting replays working properly.

Here are some good articles. You may need a gamasutra login. It's easy and free to get one.

http://www.gamasutra.com/features/20010713/dickinson_pfv.htm
http://www.gamasutra.com/features/20040204/wagner_pfv.htm
do unto others... and then run like hell.
deterministic engines... brrr...

what you suggest is the way to do it. That or sampling the game every 10 frames and interpolating, but you don't really want to go there, although it offers you the possibility to rewind/step forward a lot more easily.

Really think hard about a replay system, it's very very tricky to get right, and when it goes wrong, it's generally un-recoverable. You need to write thourough debugging tools, so you can catch the slightest discrepancies. One nice debug I used once debugging a replay system is to record frames (either every one of them, or every 10, ect...). And compare the results. That made it easier. Most of the time, small discrepancies were due to the physics not being 100% deterministic (the order of collisions, for example).

Personnaly, I'd record all incoming packets from a client, like disconnnections, connections, weapon swap requests, ect... You may find that a missed message can influence the replayability, no matter how small it is. Then you can try and filter out the unnecessary packets. That's the advantage of a replay system, you can record once, and replay endlessly until right.

BTW, another article I've seen, about a networked Star Wars game (Tie fighter?), using input playback a LOT as part of the networking process. That was in the days when broadband wasn't that available.

Ah, tere you are, somewhere at the bottom of the dickinson article.

Everything is better with Metal.

This topic is closed to new replies.

Advertisement