How to record and playback a game session?
Hello!
A friend and I are building a driving simulator in Unity, aimed at driver's training. We have a drivable vehicle for the trainee, a weather system, a ToD system, and a traffic and pedestrian system that spawns and de-spawns a limited, modifiable amount of animated cars and people, keeping them a certain distance from the player at all times (they respawn if they are too far from the player vehicle).
The weather, time of day, and maximum amount of spawned vehicles/pedestrians can be modified at runtime by an instructor, who communicates with the simulator using MLAPI (same project and same scene, you choose which "mode" to play as when starting the sim, and different GOs are enabled/disabled according to that choice: the actual sim for the trainee, and a UI with sim options for the instructor).
The last feature we're looking to implement is a recording and playback feature that allows you to record a simulator session, store it in a disk, and then play it back so that an instructor can see the simulation from different camera angles.
We are thinking about somehow storing the state of relevant GameObjects (player, cars, pedestrians, traffic lights, weather, ToD) captured every second or so, and then for the playback generating the GOs and setting the recorded states in order.
We are looking for some pointers on how to actually store and read the data. Position and rotation are pretty straight forward, but how could we handle stuff like a new vehicle or pedestrian being spawned? Or animations being played? And once the recording is made, what mechanism could we use to generate the required GameObjects and setting their states?
Any help is appreciated!
Thanks in advance!