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

Something like the following, where pressing space will rewind back 150 recorded positions :

Thank you.

So if I switch what you did to a collision trigger with another object instead of the space key, it should do the same thing, correct?

Because I tried that and it didnā€™t work unless I make the colliding object also a physics object which it then bounces against which is not what I want from a power up. Either way, it seems to only work once per round. It also does show the whole rewind. I would much rather it just jump back strait to where the character was rather than show the whole rewind. Is that possible?

I wouldnā€™t recommend using this extension to control physics affected positioning in itā€™s current form, suitable for platform & top down controlled games. The movement rewinder is purely based on position thatā€™s changed by adding values to the current position co-ordinates.

Physics is based on mass and forces (including gravity). and blending the two is a recipe for weird behaviour.

To use it for physics based movement, youā€™d have turn off phyics behviour on the object while in rewind mode (to prevent the physics rules being applied). Youā€™d also need to store more than just the objectā€™s position; things like the forces being applied (like impulses, torque, velocity) so you can reset these correctly during the rewind. Youā€™d also have to consider the other objects it interacts with, and storing their information too.

So maybe I should not use this in a physics based game?

Iā€™m trying to do something that the player can earn that will get them out of a situation where they are stuck and canā€™t keep playing because of where they landed with the physics.

Do you think maybe a power up that will make a button pop up on screen (itā€™s a touch based game for phones) that the player can press to trigger a force to push the player up so they can keep going would be a good solution? Any other thoughts?

That sounds like a decent compromise, as long thereā€™s nothing above the player to prevent them rising.

if itā€™s a touch based game, would allowing the player to be dragged round for a short period of time be an option? Youā€™d use a mouse joint, which is a physics based connector, so it keeps in line with the physics engine.

I suppose having a player earn a button that pops up on the UI that when pressed allows you to for one touch and release to fling the player could be cool. Is that what you mean?

Kind of like a flicking action? Your idea sounds neat, and different to what other games provide. Go with it :smiley:

1 Like

I just wanted to add that the Animate Shadow Clones extension can be used for this.

You could keep the shadow clone hidden (or leave it but with low opacity).

When you are ready to swap, you just set the player position to equal the shadow clone position.

Have fun!

1 Like

@tristanrhodes, would that work with Physics? Say the player is bounced up into the air off a surface, and you swap it to just before it hit the surface, would the foces be down towards the surface, or in an upwards direction?

Flicking, exactly. Thanks! Now I just have to figure out how to do it. HAHA!

I saw an example file that had the ability to touch and fling a pea (or green circle?). I will open up the actions on that and see if I can figure out how to use it. I would assume I can turn on and off that ability each time the player presses an onscreen button that will only show up once the player hits the power up, then vanish once it is used. Though when I played with that example a month ago, you could technically touch and grab the player and drag them anywhere through the level, so Iā€™d have to figure out how to limit it to just a flick.

As @tristanrhodes mentioned: That could be a great option if it does work with physics objects.

Great question! The extension currently knows nothing about physics (however, it could be modified to save angular and linear velocity, forces, etc).

This means that if you do what I suggested, the player would teleport positions but still keep its existing physics speed/momentum/etc. Depending on your game mechanic, you might want that. But if not, you could stop all forces immediately after moving the position of the player.

Like I said at the beginning, there is no way to ā€œrecallā€ the previous physics state without adding that feature to the ShadowClone extension.

Thanks for the response. I think if it just teleports the player to a place they were a few seconds earlier, and then the physics kicks in from that location, it will be fine. Iā€™ll try to implement it later today and let you know how it goes.
If it works well, I may work on the ā€œflickingā€ idea as a separate power up and have both in the game.

1 Like

As far as the flicking idea, I think it would require a mouse joint on the physics object that follows MouseX/Y. I donā€™t think you would have to do anything special, but I havenā€™t tried thisā€¦ it could be fun!

To keep it from making things too easy for the player, I will probably need to figure out how to limit the playerā€™s ability to move the sprite more than 200 or 400 pixels from where ever they were when touched, otherwise they will just be able to drag their player sprite to anywhere in the game.

Good point! You can record the position where a touch started and then compare that to the current touch, and if the distance between those two positions is greater than xxx pixels, then delete mouse joint. (You could also check if the player object touches something they shouldnā€™t be able to go over, and delete the mouse joint)

I will try to figure out how to do it that way. Iā€™ve only been using GD for a couple months, so Iā€™m still learning. If I canā€™t figure out how to implement your suggestion, Iā€™ll come back and let you know.
Thanks!

1 Like

@MrMen and @tristanrhodes
I was thinking I could activate the ā€œgrabbableā€ behavior when the player presses an on screen button that only shows up after the power up. Then limit how far the player can be moved (300px?) and make the button go away after the flick has been used.

I found the action for activating/deactivating a behavior, but so far I havenā€™t even been able to get the begining part to work. I am just working on the button press to set the player to draggable, but itā€™s not making it draggable. Hereā€™s the actions I have so far.

I added a sound for when the button is clicked and the sound plays, but the dragging part does not.

Though, I just tried setting up the button to move the player using linear velocity on the Y when the button is touched. This works well. It gets the player up off the floor when they are stuck, and looks like the player is getting flung in the air, but I donā€™t have to worry about the human player dragging their on-screen player all over the place.

That said, if anyone has an answer as to why the draggable idea isnā€™t working, please let me know.

I think you might need to disable physics behavior before enabling draggable behavior.

However, this also means that the object would not keep moving after the ā€œflickā€ was done because physics doesnā€™t know the object has momentum.

Mouse joints or physics actions (forces, impulses, etc) are the only ways to tell the physics engine to ā€œflickā€ the object.

I keep forgetting that physics objects have their own set of things that work with them. Thanks!
Thanks for also creating the shadow clones. Even if I donā€™t use it on this game, Iā€™m definitely going to use it for another one.