Last week I said I needed a vacation, and I almost took one! Instead, I worked on something I find infinitely exciting — implementing a replay system in Bleed 2! This will be a continuation of the replays post I made a few months back. It will also be very wordy, sorry about that!
Implementing Replays
A quick refresher: I’m storing the user’s inputs every frame and saving them in a file. When it comes time to watch a replay, the game uses the saved inputs to reproduce the playthrough. I call each frame of input ReplayData.
I need to make sure there’s no difference between the player controlling Wryn and a replay file controlling her. So, even when you play the game your inputs are converted into ReplayData before they go to Wryn. When you watch a replay, the ReplayData comes from the recorded file instead of the player. Either way, Wryn is getting the exact same kind of information at the exact same time.
Problems
Once I re-coded everything to work this way, I started running into problems. A big one was handling menus — menus aren’t part of replay files so they aren’t controlled by ReplayData, and ReplayData isn’t created while they are active.
An example of when this is an issue: the game is paused. You select ‘return to game’ by pressing the jump button. You weren’t pressing the jump button before you paused, and since Wryn hasn’t gotten any new ReplayData since then, as far as she knows the jump button is up. As soon as you un-pause, fresh ReplayData is created telling her the jump button is now down, causing Wryn to jump or air-dash when you didn’t intend her to.