[Solved] How do i save game progress?

Hi so basically im making a game and there are multiple levels. To unlock more levels you need to beat the previous ones and get the crystals that are hidden in the level. I managed to make the level selection work, but is there any way i can save the crystal count when you leave the game so you have the levels you unlocked saved?

:wave:
Sure you can do that.
Please check the wiki and example projects when you have questions. :slight_smile:
https://wiki.gdevelop.io/gdevelop5/tutorials/storage-action-explained

2 Likes

Yea, i already saw that post, i forgot to mention. I really don’t understand it.

There is a save-load and level-selection-unlock example.
It’s very simple, you just need a Storage Write action to save your variable and a Storage Read to load it.

2 Likes

Alright, thank you i want to copy the code but i don’t know from which point is the character dragging part. Sorry if im annoying.

For save and load itself you only need this one action.
I don’t know what you already have, but this is what it might look like.

2 Likes

Yes, that’s exactly what i needed thank you very much!

I did already make the unlock level thing work, do i need to put that id variable u put in the code or? (Also is it global?)

The ID is only there so that you don’t need a separate object, conditions and change-scene action for each level-button. global is not needed for this.
You can also do it without ID, with a more manual solution. But in most cases it makes absolutely sense to do it like in my example.

We’ve a tutorial for it.

4 Likes

Im new to this save stuff so idk how these things work, i followed the video step by step and it doesn’t work, probably because im using it to save level unlocks and not like the number thing he did in the video but i have no clue how to incorporate it for level unlocks. Maybe i could try saving achievements and all the levels are unlocked instantly?

Yes, the videos and examples do not show exactly what you need. But like I said, it’s just a single load and save action. It’s just like using a global variable.
In your case you only have to save the crystals and not the unlocked status for each level.
And about my screeshots you said “that’s exactly what i needed thank you very much!”. So I don’t understand what the problem is.

I sound like a douchebag now, i made that comment before i tried it out, im going to try again and figure it out. Il reply if i managed it or if i need more help. Thank you very much for replying to me all this time!

Ok so… i recently got back to the game. I decided to make the game’s progress achievement based. So basically you complete the level, you get rhe crystal at the end and then i made a protection system so that it replaces the original crystal with a diff one just so that you can’t farm crystals at one level. Ok so basically you beat all the levels and then you get a green checkmark which indicates that you got the achivement. But the problem is i want that green checkmark to save after you quit the game but i followed the video and it doesn’t work. Thank you in advance i will try to find a way in the meantime.

Maybe you can share screenshots, how you try it.

Ok so i followed the video and i saw something from other forum posts and also like i want it to save when i quit the game, maybe if its to complicated i will just ditch the idea of saving and il find some way around it.




Each image is in a different scene so i named the files so its easier to conclude.

Oh gosh peanutbutter :ok_man::sweat_smile: Ya some things are wrong. Actions after the scene change event are never executed. Trigger once missing and overwriting values, etc. etc.
Let’s forget the video and json, define when exactly what should be saved and loaded. It’s a lot easier than you think. But I don’t know how to explain it any better than I already did. If you want you can send me the project in a private message.

1 Like

So i put the save and load button in the achivement scene and then whenever i exit the game the achivement completion will load?

And how im i supposed to save the crystal count then? Maybe i could just make the crystals save in the level selection and call it a day?

I have created an example project for you.
It saves collected crystals when a level is finished and loads when the app is started. It unlocks levels depending on how many crystals collected.
https://workupload.com/file/4u4SHTNGfKH

3 Likes