Hello! When changing levels in the project, the level data is saved (if you return to the same level), but when exiting the game and restarting, the data disappears. Why might this happen? In this case, I am trying to save a deck of cards by clicking the “Save Deck” button. When I go to the main menu and back, the deck appears in the list of saved data, but when I exit the game and restart, it disappears. Please help.
Do you have a SaveGame object that you save to and actively load from on start up?
Typically you should have a check if a SaveGame object exists and if it does you should load from it.
Something like this:
Yes, I have a SaveGame object, and I save and load it. I tried simply saving the value 1 in a variable within SaveGame if the deck is saved, and resetting it to 0 if the deck is deleted, and the game saves this value. But when I try to save complex data (an array of widgets), the indices in the array remain, but the elements themselves disappear. Could this be related to the complex data I am trying to save?
SaveGame Object should save any values you pass to it, as long as it is set up correctly in the actor itself.
Are you overriding the save when you change level and that resets the previous state?
I start the game. When changing levels, all the saves are present, but when I exit the game and re-enter, simple values (like booleans) are saved, while complex ones (like an array of widgets) are not saved, even though I can display their indices on the screen.
I have an array of structures, each structure contains widgets that have an image and a list of cards.
At this point it would be useful to get a view of all the places your call your save and load game logic, and also how does your savegame object looks like.
Interestingly, when I clear the array in the save by pressing the Clear button, CardStuck does not display the message “deck not valid” during the Construct stage, but when I change levels and return to DeckBuilder, it shows “deck valid. added.”
Where do you pass the values to CardGameSave → DecksArray?
In the last screenshot, I create a Deck widget (Deck WB) and place an array of widgets (cards) into it. Then, I add this widget to the decks array in CardGameSave.
CardBase is array of cards
Can it be because your are trying to save a widget?
Can you try to save CardBase array directly in Decksarray?
ok, i try it tnx <3
I created a structure that contains an array of cards. In SaveGame, I created an array of this structure, so now I have an array of arrays of cards. It still doesn’t work (again, everything is saved between levels, but when I exit the game and re-enter, everything disappears).
I made it even simpler: I created only one array of cards for one deck, but it still doesn’t save.