Search code examples
replay

Playing a recorded game replay


I have a problem with playing a recorded game replay. The replay data consists of tuples of the timestamp when user input was made and the input itsself.

Each frame while playing the replay I try to find a matching user input in the replay data. But as the time in each frame mostly never matches a timestamp in the replay data exactly , I can only fetch the closest timestamp from the replay data which averagely differs about 0.01 seconds form the current frame time. This makes the replay very imprecise.

What possibilities do I have to react on this difference?


Solution

  • Found the soloution myself:

    If you want to record demos using only the userinput two criterias have to be fulfilled

    1. Have a fixed game update rate, not depending on the FPS
    2. physics have to be deterministic

    because both points are not easy to implement I decided to use frame snapshots to save the demos. this results in more data to be saved but is way easier to develop.