What I was aiming at creating this Asset was a system that keeps track of one or several objects position and rotation at a certain point in time. I started out creating a struct RecordKeyFrame to hold those values.
The recorder script is basically a little state machine in itself that does take care of recording and replaying in different modes. I included a regular replay, which replays the scene in its normal timescale, a fast forward mode, a slow-motion mode and one for rewinding, which plays the scene backwards. I am aware that there would be a bunch of other things you could do – so I made sure to give you the option of tweaking the timescale values in the inspector.
The RecordManager class is responsible for triggering a state. In the case of my example, I am working with UI Buttons – but you can tailor it to your liking and just wire it up however it is necessary for your game. My solution is basically just meant as a guide and a demonstration aid.
The Recorder Script does record the movement and rotation of the game object it is attached to, therefore it should be attached to any object you want to record.
The RecordManager has to exist exactly once in the scene, just like I did in my demo scene – you should attach it to an empty game object in your scene.
I’ve put together a simple demo, which will also be included in the asset as your example scene. You can choose how you want to replay the scene with the UI Buttons to get an idea how the different modes will work.
Press the Link down below to try the demo!
This system should be fairly easy to integrate into your existing game and in order to prove that, I made a very simple race game where you drive one round and after the round is finished, you’ll see your replay in the background.
Play Alien Race on Itch.IO…
or Download it on Google Play!