[SOLVED]Saving and loading/ checkpoint

In events of Main Scene
Add
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

Hi Zayddah,

As promised, I looked over my game file. I made a new update in my old thread with more details in the link below. It’s the long one at the bottom with all the screenshots. However, I should tell you that this is a general guide and it may not help with everything.

One thing I’ll say here is that I agree with Zero’s last post just above. Instead of having three Save actions, make a Parent Global Variable and then a few Child global variables (health, positions, etc,) under the parent, then have your programming revolve around saving the data from the Parent variables (which includes the data on the Child variables). My new post on my thread touches on that, I believe in the Player Extension part.

1 Like

hi the only thing that i can say. “This Is Hard asf” my mind is not working anymore.
and as you said before the multi scene idea is hard for me now. im giving up on that idea cuz its blowing my mind for now i want just to make a Save/Load Checkpoint System In this system, colliding with a new checkpoint will delete the previous save and save the new one. with the posibility of saving the player’s health thats it and if u think that i didnt try i swear it has been 7h straight that im working on this but still it didnt work i tried different method but it doesnt work. and for @Jules-Mado-Games method for me it’s a bit hard so i cant do it . if no one want to help i understand it i know that i am so annoying :smile: :smile:

1 Like

That’s alright if you wanna step away from this part of programming for now. I only started learning about storage, saving, and loading around… a year or so after I started using GDevelop. Even now, I’m still learning. I needed a lotta help, too.

Best of luck with your game and I’m sorry we couldn’t be much help. :sweat_smile:

I’m sure the more you use the software and learn new techniques, things will start to get easier to understand.

2 Likes

Thank you man you did a lot :heart:

1 Like

You’re welcome.

I don’t know if you read through my whole thread you’ve been using to help you with this or read the last couple of posts, but I recommend skimming through the rest of it. I remember at one point making a post where I declared that I was giving up. I thought about deleting those posts because they make the thread really long, but I decided not to because maybe the people who are also struggling with programming would read those parts and feel a little better knowing that they weren’t alone with the struggle. XD

XD. I’ma do it right now and see if I get it work I’ma try more than my best :heart::muscle:t3:

Giving up is easy
And you have here many ppl who can help you solve your problem so it makes no sense to give up

So
I did what you need and checked every aspect of it if it works and it does

Just to be clear event is combination of condition and action
You can have event without condition so it runs always

I have global structure variable with 3 children
HP PosX and PosY
HP of player is displayed in upper left in game

1 - At beginning of scene i am hiding DeathLayer (for you it will be layer with respawn button but since i am lazy i have only there text)

  • I am loading here that global structure variable Saving
  • You need these 2 events load and convert for it to properly load

2 - Because even so i have global variable HP set to 100 by default if save does not exist it sets it back to 0 that’s why this event check if it is 0 and if it is it sets is back to 100 (otherwise you would start game on death screen with 0 HP)

3 - Here i check if variable PosX and PosY are equal to 0 if they are (which means you did not make save YET same situation as above) i change position of player to default spawn point and center camera on him with trigger once so camera can catch up if you move

4 - Here i check if variable PosX and PosY are NOT equal to 0 if they are (which means you did create save file) i change player position to that variables

5 - If you collide with tree you gonna constantly lose 1 HP

6 - If your HP is 0 or less i show here death layer and delete player

7 - If layer is visible (meaning you died) and space key is pressed i hide death layer change HP back to 100 and again center camera on player

  • Again same situation as in point 3 and 4 where i check if save exist or not just by checking if Pos variables are equal to 0 or not

8 - If they are 0 i move player to default spawn point

9 - If they are not 0 (meaning save with some position exist) i move player to that Pos variables

10 - If player is in collision with farmland (this is your checkpoint object) i save player X and Y positions to PosX and PosY variables

  • Then i perform a save

11 - Press X key to delete save file (it is just for testing)
12 - Press Z key to save on demand (normally you auto save when you die but if you want to test if HP is correctly saving for example drain your HP down to 70 then press Z to save then close and open game to see if HP will save then this is why it is there)

  • Wherever you see Trigger once in condition it means it needs to be there and where you don’t see trigger once it means event needs to run WITHOUT it
1 Like

To be Honest man i dont know how To thank You .the way you explain things made feel stupid i swear :sweat_smile: :sweat_smile: .
so for the other things like coins and stuff i should the same thing because now its clear i can do my work now i kinda understand now how the Storage System works because of you
and not to forget about @Drona and @Jules-Mado-Games that helped too thank you so much

1 Like

For coins you use Instance variables and give each coin ID variable
Create new topic titled
How to make/use Instance Variables
Again this is ultra easy but someone needs to explain to it
On other hand i bet you can find it just by using search option in upper right of this page

So maybe 1st search and make topic if something still is unclear for you

As for coins again do not delete just hide
But you will need to keep track of which coins are hidden and which are not

On top of that i think you will also dive into arrays for coins and that type of variable i did not explore but i bet it is stupidly easy as other variables

General idea is
You want to create events that will automatically give Instance variables to each coin and that i know how to do
But next you want to put them in array (idk if structure variable can do it cause i never did it again use search feature)
And so you would then prepare event that would check if coin is hidden or not or if its opacity is 225 or 0 and save that to variable

Some learning ahead of you but as you see everything is doable if are determinated
When you master instance variables you will have knowledge to switch check points into activated or not

For example you can have 3 animations for each checkpoint

  • untouched
  • already activated
  • your current checkpoint to which you will go back after respawn

THX to instance variables
On top of that not in like my example you would teleport to position of player where you collided with checkopint
You could set player to always spawn like left from or right from or on center of checkpoint you can even adjust how far or close to whatever position of checkpoint
Which would look more elegant and made a lot more sense

I seen you on gdevelop discord
You think i am some kind of smartass that know all that crap out of air?
In upper right of gdevelop discord type ZeroX4
find all my messages and sort by oldest
Go trough like 2 or 3 pages of my oldest and look how i was literally asking after someone told me what to do
But where is that? Where do i click? What is event block?
It is all there
We all started somewhere do not feel shame in asking for help and do not feel bad because you don’t know something
You are here to learn and there is no other way to achieve what you want other than learning

one last thing i want to know before i go is how can i set the animation of the checkpoint like when the player is onclission with it like in the photos



the problem is when the player collide with it they both activate like this
2

here to test out :

use F: to enter Houses

Thank you so much i really appreciate your help you have done a lot for me :heart:

1 Like

Player is in collision with object
Change animation of checkpoint
BUT my method does not save animation of checkpoint
Like i siad in previous post you will need for that instance variables to save that animation

My method will work for changing animation as long as you don’t close the game

1 Like

ah ok i get it thank you. :heart: