Replay Game

Hello Everyone,

We want to implement a replay feature in our game. Our multiplayer is working using ECS Netcode.
After some research, we have seen that we can record the game and save it as mp4. But it will be very expensive to store all the videos on AWS.
The other option, we found, is to store the inputs of players and make it possible to launch the game and send those input to recreate the game…

Regarding the last option, how would you implement that ? (any suggestion or idea are welcome) :slight_smile:
If there is a better approach, i am all ears.

@timjohansson @CMarastoni

Best Regards,
Ali

any help please ??

@timjohansson @CMarastoni

Yo!
So the answer can be quite involved and complex.
But simplify things a little bit, storing the input will not work, unless you have a completely determinstic gameplay. And because of the multiplayer for sure isn’t (since the packet arrival rate and loss aren’t deterministic).
There best you can do is probably to store two “tracks”

  • the received snapshot data from server (with some timing information if necessary)
  • the input of the player for each tick
  • there received RPC or something similar (in case RPC does gameplay logic).

Then when you replay, you will need to create a fake connection (sort of) that will fed the NetworkStreamReceive system with snapshot data from the a that record buffer, with the same timing you had received from the server during the your original game (the same tick pretty much to start with).
The player input also need to be faked in a similar way, by creating some system that fetch the input information from the recorded buffer.

This is to sketch the idea (and scratch the surface)

2 Likes

@CMarastoni Any plan to make a sample project for this replay feature or even better integrate replay feature into dots netcode package out of box?

No real concrete plan yet on demo or sample. But given the importance, it is something we may explore in some future sample

3 Likes

With esports not going away, I think it might be a common need for a sample so add me to the list of interested people! :slight_smile:

Even for single player sport like games.

thank you for the answer because it is very constructive!

I have another question, do we really need packet arrival rate and loss data? game replays represent server-side gameplay, as it is the only source of truth.
a replay is intended to show the game representation of a server version but with a client visual perception (Animations, vfx, lights…)

I think the networking stuff needs to be taken out completely when it’s about replays.

at first sight, i see 2 ways of doing it:

  1. Full deterministic Gameplay:
  • in this case, all you have to do is saving the inputs received by clients per tick on the server side and play the game again :).
  • Obviously, if the time skip/inversion is needed, it will take more effort to implement.

btw, it’s not impossible to accomplish fully deterministic gameplay as a lot of games already do that.
EG: league of legends, they provide a lot of dev informations in their TechBlog: https://technology.riotgames.com/

  1. Non deterministic Gameplay:
    A - saving all server snapshots to replay the game, but this will be very costly in term of replays size.
    B - saving server received inputs as if it was fully deterministic and few snapshots to fix the wrong mispredictions.
  • also using Soft floating points can greatly reduce the impact of float calculations mispredictions.