Restart button(Help how)

Hi i am here 1st time i’am from Poland so forgive me my language.
Please anyone how can i make a restart button on the screen.
I wonna to work like this…
player is moving and touch the checkpoint when people playing make a mistake then pless the button on the screen restart and landing in last checkpoint touch by the player witch all scores and witch no restarting all level…i try do this but i thing i just don get it…looking for tutorial …reading but just don’t finding enything.

Mmmh, search for “checkpoint” here in the forum, I think something like this has been asked before :slight_smile:

The idea is, when you collide with a checkpoint, deactivate all the checkpoints and activate the one you’re colliding with, to de/activate use an “enabled” or “active” object variable, set it to 0 to deactivate the checkpoint and to 1 to activate it,

Then, when you make a mistake, pick the activated checkpoint (a condition that checks if the “active” variable is = 1), and move the player to the checkpoint position:

Shouldn’t the very last condition be

Variable active of Checkpoint is = 1

Haha, yes! :smiley:

Hi againe…
Still problem, i use the answer for my question but its not work…but i was thinga about this and maybe someone give me another tip… a have 2 buttons one is reset and other is save position… how can i set it up…how to wright to variable saving position when play game x.y. and when i press a reset button just player back to this save position…i try set this up but player is just read from one position on game and always at the same like a wright is not working.

Better show us the events :slight_smile:

If the position is always the same, that arbitrary point, probably it’s the world origin (0, 0), it would mean the expression to set the position have errors.

Hey… um… event i change a multiple times becouse i test every ideas but still nothing…sed me…heh

in 100% i do something wrong from 2 day’s i just missing something even i read every possible post…now i stop on this but it’s no sens

To be honest, I don’t even understand wath is your intention with those events; but I can see you’re rewritting the same field of the same file twice.

Also, you don’t even try to do what Lizard told you.

Questions: thi is about a restart button with checkpoints, not savegames, right? Why are you writing files to restart a level?

I don’t have the URL handy now, but someone wrote a GDevelop tutorial about using a Finite State Machine model for game logic. (UPDATE: GDevelop Tutorial Finite State Machine ). Think of a finite state machine as a flow-chart. Each Box or ‘node’ in the flow-chart is a state. When you enter into a state, you can execute actions that are appropriate for that state, and then you can allow transitions from that state to some defined set of other legal states. Those transitions can happen as a result of an event. Also, in addition to the game as a whole having states, individual objects (the player, enemies, loot chests, scenes) can have states.

You may possibly want to consider the use of a finite state machine, and when the player clicks the “restart” button, just transition to a state that initializes the scene/level/stage? If you have checkpoints, each checkpoint could be a different state that you transition to which causes it to initializes that stage again.

That state could do a few things for you: Reset the player state to whatever it was at the beginning of the stage (for example, if you had saved player health, mana, inventory, and other variables, when they first entered that scene/state, you could then reload those saved values to reset the character to their state from the end of the previous checkpoint, or maybe you just reset their health and mana to full [your game might not even have health or mana as concepts, I just use those as examples of state], as well as moving the player character sprite and camera to the correct position in the stage; and also, reset the state of the stage/scene. For example, if you need to re-spawn enemies that were killed, reset timers, reset loot boxes and other scene/level/stage state, then the “parent state” that re-initializes the scene could trigger all the objects in the scene to reset their states (that is, each object might have it’s own state that gets recursively reset from the scene state). Although, the scene editor gives you a good ‘default’ state that you should be able to reset the whole state of the scene by simply reloading the scene as if it was the first time you got to it.

Depending on how much state you have to re-initialize in your scene, resetting the scene state may take enough time that the player might wonder if the game is frozen while it resets, so you might also want to have that scene initialization state put up some sort of loading screen to let the player know that it will take a few seconds to reload the scene, and then hide/destroy the loading screen once it completes.

Yes, that’s a normal level restart. I know how to do all of that just reseting variables to its default value and reloading the scene, and by the way, GDevelop do that in the blink of an eye; even in my current project having +100 objects and variables per scene.

So, back to yours:
Why are you writing files to restart a level?
Do you want to save a game and load it before or do you want to restart a level?

Well, you’ve a problem with quotes right there:

  • Point names must be entered without quotes: PlayerHitBox.PointX(Pozycja)
  • Almost sure filenames must be between quotes: “PlayerHitBox”
  • When you read a value from a file, the variable name is without quotes: Pozycja

And, as I say, he is writing two values to the same field. So, is automatically loosing the first value.

But solving all of that… writing a file will restart a level?

There’s a difference between restarting a level and load a saved game, and I think this is overly complicated to just restart a level (something very simple).

He’ll frustrate. In a pedagogic view of things, I don’t think this is even in the Socratic Method path.

Umm, I didn’t say anything about writing files? I said something about saving state - that need not necessarily be to a file; you could just clone an object, and keep the copy around in memory. It all depends on what you want your game to do. For example, if you have player health level or other state as a concept in your game, when the player reaches the checkpoint, you might want to save off that info, so that you can reset the player when you reset them to the checkpoint? Or maybe not, maybe you’re happy to keep their current state, or maybe your game doesn’t have player state other than what gdevelop has built in - animation, position, and motion.

No, but that’s what the user who open this thread is doing in his project.

No, but that’s what the user who open this thread is doing in his project.

I don’t understand why nobody can see that’s the first mistake to solve.

Ok. Well, that’s true. I was never saying their approach was correct. I was simply suggesting that using an FSM might be a helpful way to simplify the complexity of resetting state of the game to a previous point.

I could see, in general terms, the value of writing values to a file to save progress to reload later if the player quits the game then reloads, but it’s not clear to me that their code is even correct for doing that. It looks to me like they have a bug that could cause them to lose their saved state upon reload.

I guess Adam Ślązak has given up by now.

Please don’t say i not try…i try…i even tray change to the buttons this idea… i draw what i wonna do if i whirgt wrong… to be more uderstable.3Rd day by now i will not give up …i still try…i know i make a mistake but whare??


I though you were talking about a “real/physical” checkpoint, an object added in the scene that you can collide with.
If the checkpoint is an object, the variable must be an object variable, you’ve to flag this checkpoint with a variable. Check my first image, the first reply, “Do = 0 to the variable active of Checkpoint”, also you have to move the second action that modifies the variable to the next sub-event.

Now, if you want to save wherever you want, just pushing a button, there’s not a Checkpoint object, you can’t collide with it. Instead, when you press the save button store the current player position in a “X” and “Y” variables:

Conditions: Mouse Left button pressed Cursor is over SaveButton Actions: Do = Player.X() to the variable X Do = Player.Y() to the variable Y
And when the reset button is pressed, set the player position = Variable(X) ; Variable(Y)