0
Answered

Question about saving data

Pandar 3 weeks ago in Game Creator updated 2 weeks ago 6

Hi. Can someone explain, or provide a link to a tutorial on how to save certain data in the GC (the amount of money collected, clothing purchased by the character and stored in the inventory or dressed on the character) between the game levels and the game sessions.

Maybe someone will share a link to a test project with implemented saving, and I will try to figure it out myself?

Unity version:
Game Creator version:
Answered

Hi Pandar;

Saving/Loading is done automagically for your. There are some limitations though, explained below. The idea is that you just have to use the "Save Game" action when you want to save the game and the "Load Game" when you want to load a previously saved game.

Coins, inventory items, quests progress, ... all these things are tracked and saved automatically using the aforementioned actions.

However, not everything can be done like this out of the box. Unity can't serialize (aka save) game objects, so we can only track objects that are not created at runtime, only in editor-time.


Hope this helps!

Thanks for the answer. And I understand that in the play mode, when you go from level to level, the number of coins collected, purchases, etc. - are saved. But I can 't figure out how to save this data between sessions. Turned off the game – turned it on again – and everything was gone, no coins, no purchases .

The saving isn't done in a background process. You have to explicitly tell Game Creator when you want the game to save. For example, have a dedicate button in your UI that says "Save". When clicking this button, all you have to do is call the "Save Game" action.

When you load your game, you should execute the "Load Game" action, which will load the previously saved game.

If you want to continuously save your game, you can always use a Trigger "On Start" and execute the following Actions:


- Wait 0.5 seconds

- Save Game

- Restart actions.


This will ensure that the game is saved every 0.5 seconds.

Thanks. This is understandable. But can I choose what I want to save? For example, I don 't want to save the location of a character. I need to save coins and clothes, and the character should appear, when loading, at the beginning of the level.

+1

Move the character to the desired position before saving

Thanks. Good idea!