How to create a system to go back in time as in Prince of Persia?

Well, I would like to create a system that allows the user to go back in time in the style of Prince of Persia, but I have no idea how to record the movements made, and then pressing a button, load the recording in reverse order .. .

Could you help me with some code or idea?

Thanks in advance...

Hi,

Maybe you should record the types/order of the player's animations and his movements on x seconds (or when the player can reverse time). Whenever the player's animation change, you store the animation ID an array with the player's position in the Update function.

And when the player press the "reverse" button, you read the array.

Dunno if I was clear enough but hope it will help you.

Use linkedlist.
When the list is x in size you can remove the first and still add last.

And example:
LinkedList reverseTime = new LinkedList();

In every update
AddLast
Remove first if LinkedList size is to big

Remember to do it on visible enemies.

The movement class should consist of transform (orientation and world position) and or more info depending on gamemechanics.

Or you could make the timescale negative?

TimeScale = -1.0

or something like that, look up the TimeScale method it is used to slow down time in my game, and should be able to reverse it.