Save Item/Object permanently?

I have make a Plattformen game with 9 different levels which works all fine. In some levels my character is searching for a key with which he can unlock a door to get to the next level. All works fine.

But now I want to create a hidden level, which is located on my menu-screen. To open the hidden level my character has to collect a key “in” a level (and go back to menu-screen to unlock the hidden level). Is there a way to “save” this key so I can use it when I go back to the menu-screen? At the moment all the progress my character learns will only take place “in” the levels, but when I go back to my “level-selection-screen” all the progress (finding key) vanished.

I hope you understand what I mean. Sorry for my mediocre English!

best Rimbaud

hello, and welcome @Rimbaud!
So I think the best way to let that happen is by storing it in a global variable.
global variables are just like normal variables except that it gets stored so you can call it from any scene,
here is a tutorial from the official gdevelop youtube channel:

but if you want to save that the player has the secret room Even if the player reloads the game you can use the storage system, here is a tutorial for that:

I hope this helped, and I wish everybody a splendid day.
-potato

1 Like

oh lord … this helped me out! Thanks so much for the brief answer! best Rimbaud!

Hey there

Now I have still one issue with my Plattformen depending my “secrets”.
The player can find some “legendary items” in the game. When he collects an item in a level (for example Level 2) - due to global variables - he can see his collected items in the menu-screen, where he can unlock a secret room. That works fine.

My problem is: When the player goes back to “level 2” there is still the “legendary item”. I need to “delete” the legendary item permanently during the game-session (after the player catch it “once”). Otherwise the player can go back to repeatatly to level 2 an collect the legendary item again and again …

I hope my explanations were understandable

best, Rimbaud

At beginning of scene 2, you need to flag something as a condition and in action put, delete legendary item. So, if you store it in a global variable you can put, if the item is in global variable, delete legendary item. But what if you remove it from the global variable when you unlock the secret room? Then you need something else like, globalvariable hasLegendaryItem = true then action delete legendary item. Anyway you get the idea and will know how to apply it to your game in a way that makes sense.

1 Like

Thanks so much for your brief answer.

The problem here is: In my game the player needs 5 legendary objects to open the secret room. This 5 legendary items are hidden in my 5 levels. At the moment the player can collect all 5 legendary items - if he wants - in one level (for example “level 2” … But the mechanic should be that the player has to collect 5 legendary items in 5 different levels, to finally can enter the secret room …

I really don’t know how to handle that

best, Rimbaud

Use boolean like lucky-j said.
Add in the global variable legendaryItem1Collected=false then in the level 1, at the beginning if legendaryItem1Collected=true then delete legendaryItem1 object (I assume you already add this object in the scene editor).
Also add another event when player is in collision with legendaryItem1 object then change legendaryItem1Collected=true.
For the secret room the condition is legendaryItem1Collected all the way to legendaryItem5Collected = true (5 of it must be true) then open the secret room.

1 Like

Thanks so much @pqrs and @Lucky-j … I did the boolean-method and it works very well. What a fine community here. Wonderful!

all the best, Rimbaud

2 Likes