Send the player back in time a certain number of seconds of gameplay

Is it possible to send a player back a chosen number of seconds in the game? My thought is to have a power up that when collided with, will instantly send the player back to where they were maybe 5 or 10 seconds in the game.

If possible, how would I do that? Would it keep any physics movement from that moment in time as well? That is what I would prefer if possible.

Possible? Sure.

You’ll have to do what games like Braid and Hourglass do, though. This means you’ll need to record the x/y positions/actions of the player and play them back in reverse.

You’re after a Braid or Prince of Persia type mechanic? Here’s a link to a video how another member did it.

And here’s a link to the source code of the extension.

1 Like

I haven’t played either of those games, but looked up Braid on Youtube just now. It seems pretty similar, yes.

I started watching the video you linked to. I’ll follow along and give it a go. But this looks very complicated for my low level of experience. So it may take a few tries to get it right.

Thanks so much for the great links!

The video is an explanation of how the extension works. Don’t worry too much about that, just understand there’s an extension for what you want to achieve. Download that extension and use it instead of writing your own set of code/events.

1 Like

Oh! I thought I was going to have to implement the source code.

Hehe, no, we’ not that nasty. At the start of the video @Joshua shows how to use the 3 commands he’s created - animate, record and replay (the latter is the rewind/reverse play action). Those are the bits you need.

:laughing: I was going to give it a try. Eventually it would be nice to know how to do that, but with my typo issues, it is likely to spell dizaster (misspelled on purpose… this time.).

After watching the video, I still don’t understand how to implement the extension. I understand how to use extensions, but not how to turn source code into one.

I’ve had a look at the source, and although it has an extension in it, it’s not quickly downloadable.

I’ve extracted the functions you need, and put them into an extension. You can download it in .json format from this google drive. I’ll leave the file up for a few days.

Once you’ve downloaded the extension, install it with the following (the file you’re after is the .JSON you just downloaded) :


Once in you should have an extension named Rewind Replay in your extension list :

image


You can now use the 3 functions in your event actions :

image

Wow! Thanks for doing that for me. I downloaded the file, so feel free to delete it from your Gdrive if you need to.

I installed it as an extension, but it doesn’t show up when I try to add it as a behavior to the player’s sprite. When I tried to add it as an action, I got an error message saying I needed to add it as a behavior. So I seem to be stuck.

I’ve just had a quick go with the source project, and it’s throwing an error (it doesn’t like the push function). I’ll investigate a little later today and see if I can sort it out.

Thank you! @MrMen I very much appreciate that.

I’ve fixed extension. Download it again, remove the existing one and install the new one.

It looks like the GDevelop workings under the hood may have changed slightly since the video was made.

Here are the events from my working example (Player is a draggable object), space bar rewinds :

image

Animate still gives the same error message, and I still can’t add the behavior to the main character.

Record and Replay can be added as actions though. Do I not need Animate?

How do I tell it how far to go backwards for the rewind? Can I just have it start recording at the beginning of the scene but access the rewind when triggered?
Right now I am triggering it with the space bar like you did, just to test it out. It seems like it can only be triggered once per round, and only sends the character back to the very beginning. I assume that is because that is when it gets recorded.

Animate is for platform character behaviour. I haven’t checked if that works. I just focused on teh record and rewind functions.

It records 150 frames before dropping the oldest frame (that is about 2.5 seconds at 60 frames per second. You can extend this by changing the 150 in the recorder function of the extension to a higher value :

It will rewind every time you press space. If you don’t move and the animation is named “Idle”, then it won’t record.

So you can move for a while, press space for a second, move some more, press space for a seconds etc. And it 'll rewind from the object’s current position.

Thanks! Got it working as you described.

How would I have it set to auto go back to a specific length of time when triggered? I was hoping it to work like that rather than have the player have to hold down a button until they get back far enough.

Use a counter (variable), and decrease it every frame. While it’s greater than 0, don’t record and do rewind.

By counter, do you mean “timer”? I don’t know how to decrease a timer.

No, I meant a scene variable that you set to a nominal amount (think of it as how many moves back you want to go), and decrease it.

Timers are not the right thing for this.

I spent hours googling, and reading stuff online, and couldn’t find anything that explained how to do what you are saying. I’m sorry, could you explain how to do it?