-
-
Notifications
You must be signed in to change notification settings - Fork 43
Description
✨ Description
A replay system that allows games to record, and then later replay gameplay.
Use case
Replay systems are present in many kinds of games, allowing players to analyze matches, do coaching sessions, create cool videos about their favorite moments, etc. There's also some community demand for this feature.
Distribution
Ideally, the replay system would be a separate component / module, independent from core.
So either its own addon, or extras.
Background
netfox already orchestrates gameplay logic and captures all the data necessary for it. So why not just capture that data into another stream for storing? And then feed that same data to the simulation, basically replaying the recorded game.
Expectations and wants
- Replay should require no, or as little extra code as possible
- i.e. the game doesn't need to know whether it's online or is replaying a recorded session
- Gameplay code should just work™️
- Ideally should be able to seek to arbitrary points in the replay
- Allow for streaming, so we don't need to keep the whole recording in memory
Implementation notes
This will probably end up being a huge feature, so it would be best to implement it as multiple smaller features.
- Recording
- Saving to disk is not in scope - that's up to the game itself
- RollbackSynchronizers need to expose both state and input history, preferably in a way that doesn't make it difficult to iterate on the underlying implementation
- In other words, if we expose too much, we won't be able to update stuff without breaking API
- We need a mechanism to know which ticks are final - Track and expose latest confirmed tick #470
- Whenever a tick is finalized, take a huge snapshot and pass it to the game - probably emit a signal
- Snapshots need to include a tickstamp, and node paths for each piece of input and state data
- ❗ Make sure to record RewindableActions too for the given tick
- Replay
- Must be able to stop and override NetworkTime state to manipulate tick loop
- Provide API to pause, step, seek and play recorded data
- The complex part is step - apply state, input, and trigger a tick
- The rest of the methods probably either use step, or just set some variables
- ❓ Can we refactor NetworkTime to make it swappable? e.g. the replay system could provide its own implementation with the API mentioned
- ❗ Nodes may appear or disappear between ticks.
- We must provide some way for the game to handle these cases
- Ideally the game knows which scene to instantiate for these nodes
Tasks
Subject to change as we go
- Recording
- Expose RBS state- and input history as read-only
- Expose RewindableAction state for recording
- Track and expose latest confirmed tick #470
- Track recordable objects ( RBS, RewindableAction )
- Assemble and emit recorded ticks
- Replay
- Implement NetworkReplay ( name pending )
- Can override NetworkTime state
- Can apply snapshot
- Can trigger tick
- This is just a starter task
- Implement replay
- NetworkReplay gets a
play()method that replays a session - Implement mechanism to pull tick snapshots from the game
- This way the game can handle the snapshot data any way it wants, e.g. load everything at once, stream from disk, receive from network, etc.
- For starters, assume that retrieval is always successful ( so maybe no network streaming for now )
- NetworkReplay gets a
- Support spawning and despawning nodes during replay
- Provide a mechanism for the game to spawn nodes that are needed for the current tick
- Free nodes that were created for a previous tick but now don't exist
- Implement NetworkReplay ( name pending )