Hi,
Firstly, thanks for this great example.
Even though I manged to implement it in my game project successfully, I fail to understand how values flow.
I understand the core concept of a table which records value every frame(dt) and when we press the trigger we are just setting the sprite in those recorded position data in reverse order. But I don't completely understand the maths and the code. Even after sitting with a pencil and paper and putting values in it manually I couldn't grasp the whole thing which I need to understand so I can troubleshoot parts of the mechanics and to build upon it.
Here is what I did. I basically stripped it to record just the players XY position and a different objects's Y position.
I decreased the height of the array to 4. I removed the speed function made it a fixed value.
What I'm trying to do is
A) To program it to ease into the rewind (starts slow till it reaches a maximum speed. I read the lerp can help with this but I don't know how to implement it(I tried to put it in the speed value but then I realized it's becomes a static value till it reaches the while loop))
B) Create and specify a cooldown value before the player can use the power.
C) Limit the array to record only a set amount of seconds.
D) The array retains its values if my player dies and the layout restarts. (playback the old games postions) Even after clearing the array on layout start and then adding the starting position values to it afterwords it gets stuck a the corner of the layout. (one solution would be to stop rewinding after it reaches array width one and triggering the cooldown. maybe.)
E) This is only the base event sheet which the players movement and powers so I want only the player to get his actions recorded in it. If I make different levels/layouts, I think that creating a different array for them and redoing the recording codes for the objects I want to move. Is this the right way to do it? Can I trigger an object to start recording on a certain event?
Its way too much to ask. Instead I would like to learn how it all works.
Can someone please help me understand the different part of the code and how the array is creating new rows and how 'set value at(Record.Width-1,0) to lerp(Record.At(Record.Width-2,0), Player_spawner.X,((1/60)/dt)*i)' works (especially how is using lerp helpful).
Thank you.