[SOLVED]Saving and loading/ checkpoint

Before proceeding, please use the forum search feature at the top of the page to check if your question has already been answered.

How do I…

How Can i load the last checkpoint after the player death

What is the expected result

im expecting when the player died a you died screen appeared when cliquing the restart button to return to the last player checkpoint

What is the actual result

it didnt work at all, i tried using the checkpoint extension but still and i tried the storage system using this tutorial Saving & Loading (Storage) - Intermediate Tutorial - GDevelop

Related screenshots

Hi, it seems you are using two different storages.

First you save your variable in “CheckPoint” of storage “level” but then you load “level” from storage “Storage”. Shouldn’t it be: Load “CheckPoint” from storage “level” and store value in CheckPoint?

Btw your sound name says “ChekPoint”. Is this possibly a typo?

hey sorry for the late respond! i was trying to copy the script from this video :https://www.youtube.com/watch?v=AXd1nND7zQ0&ab_channel=GDevelop

the problem is while copying it i couldn’t find the Read And Write actions maybe because its an old version of GDevelop and i have the new one so im now a bit confused about if the save=Read
and the Load=Write

Yes, the names of the actions were changed, but it is read = load and write = save.

Does it work now?

no still i tried using this method Julas medo method but still i didnt work it just confused me more tbh if u have any idea
im open to any kind of advice cuz my head is spinning right now LOL.

hey quick update!!
i made it kind a working like a 20% but it still broken :frowning:
so i tried this video example : GDevelop - How to Save and Load your game or create checkpoints in Gdevelop5
but as i said it’s still broken like when i go to different scenes and the player dies it spaws in a random place

or when he died in the main scene it respawn here:

and enable to move the player

here’s the code:

and to mention even if the player didnt collide with the checkpoint he respawn there

1 Like

I wonder if you have to have an action to delete the old checkpoint position from storage and then save the new position. I think I remember that was something I had to do.

I’ll take another look at my stuff this week and see what I can share.

Okay thank you mate!

You are aware saving to storage and loading from it makes only sense when you are closing and opining later your game?

Because i fail to understand why you would need saving to storage otherwise?
When it is just checkpoint

So lets for now ignore storage

And all you need to start from last checkpoint when game is still running and you hit restart button is

Player is in collision with checkpoint

Change Global Variable XPos set to Player.X()
Change Global Variable YPos set to Player.Y()

Now when you hit restart

Cursor is on Restart button
LMB is pressed
Trigger Once

Start game however you start it or whatever
Change player X Position set to GlobalVariable(XPos)
Change player Y Position set to GlobalVariable(YPos)

And now after hitting restart you are at the position of last checkpoint

If that is not enough for you just reply and we will proceed with saving to storage

I’ma try it right now and see where it goes

Just to add some context to what Jules-Mado-Games wrote, when you preview the game it can be useful to clear the storage Storage - GDevelop documentation

If your actual goal is to have your player position for starting the level again at some point within a play session but not keeping the information when you quit the game then ZeroX4’s approach is the way to go. I assumed you want to keep the progress also after closing the game.

i want it when the player died to go back to the last checkpoint and of course if the game is closed to set back to the last save

i tried it but when the player Died it gives me the “You Died” Screen but when clicking the button it just dont let me go back to the last checkpoint :

In events of Main Scene
At beginning of scene

Change player X position set to GlobalVariable(CheckX)
Change player Y position set to GlobalVariable(CheckY)

I told you already there is no point in making separate scene for shop
Now you are making separate scene for death screen
And you are only constantly creating problems for yourself just because you are using scene switching when you do not need to

It is like you are driving your car to McDonalds
And MDonalds happens to be 1 min away from your home IF YOU CRAWL
This is what you are doing

Instead of changing scene you could simply put whatever you have in You Died scene into some layer on Main Scene scene
And hide that layer while showing it only when well player died

Now you removed problem of position not loading because something not existing and crap like that

Really stop complicating stuff for yourself because you gonna have very bad experience with game developing

If you gonna try to do something just because you can and not try to make it as simple as possible you gonna develop this game for years and on each step you gonna come here for help doing even most simple tasks

But how you gonna proceed from now on is your choice

1 Like

i see as you said its harder than i thought it still given me the same problem and i know why because of this event

because its sets the player’s health always to 0
i tried your method but the problem that i faced is when teleporting from place to place the it shows the first background like this

anyway im gonna try something else and for @Jules-Mado-Games if u have a solution its gonna be great

This event do not set players HP to anything
It only changes scenes while checking if HP is below 5
Not changing any HP value

Your actual problem comes from this

As i assume this button with Button on it is in fact MedievalButtonBrown

Am i right?
Well i sure i am

Now this

You are currently on You Died scene and you click that button

What you are doing IN ORDER is
Change position of player to Check variables
And then switch to Main Scene

So let’s stop here for a moment and answer few questions

  • Does your player exist on You Died scene that you are changing its position?
  • Does changing scene AFTER you 1st change position of something that does not exist yet should change it position when you get to other scene?

You are complicating stuff for yourself for no reason you add scenes for no reason you are expecting something to happen just because you expect it and not because logic of events would lead to it

I am not making fun of you i am just trying to teach you to pay attention to what you are doing

I gonna stop helping you now and let other ppl try because i think you get even more confused from multiple options you are offered by us

I will come back to helping you when nothing else for you will work

Simply removing that scene changing and using layer to show or hide death screen would solve your whole problem

1 Like

i know and you’re a great teacher tbh for the other scenes im not gonna use it i tried using this events from this video right here save/load and the problem that i faced how to implement the same mechanic for the health system as he used in the beginning of the video that what im trying to figure out right now

just to clarify things and what i want to do

  • i want when the player’s health goes below 5 or 0 to die and give me the option to re spawn
  • a save and load option(checkpoint) so when the player died he returns back to his last checkpoint
  • a save point that when the player is in collision with it it saves his health and the other stuff and when come back again he starts from the checkpoint
    and im sorry if im being a bit annoying

“this is Hard i swear but im gonna keep going”

so i made a bit of a progress

what i do :

The Problem That Im Facing:

  • even if the player didnt collide with the checkpoint when he died he’s back to it .
  • when respawning in the checkpoint the player cant move arounf only the animations that are running.
  • the health stays always at 0

When you store everything in structure (like you should and that is good)
You only save and load parent variable so in this case Saving

So you should add position variables to that structure and save/load only it

Now as for your other problem i just gonna give you hint because again you do not pay attention to what you are doing

And i bet you can figure it out

If you figure it out
I will sound like broken record but you are creating problems for yourself for no reason
If you are able to save all these variables as children
Then why you try to save 2 different variables as something separate where you could just put them as children of Saving variable and only save/load Saving variable?

On top of that for each save you should have separate name for group and for storage but that is something you most likely did not know