how to save the player data before loading a new scene, and how to load the player data after loading the new scene?

Quincy Huang 5 months ago in Game Creator updated 5 months ago 7

how to save the player data before loading a new scene, and how to load the player data after loading the new scene?

Unity version:
Game Creator version:
Satisfaction mark by Quincy Huang 5 months ago
Under review

Saving and Loading the game also takes into account loading scenes, so it' a process that involves everything. Loading a previously saved game, will also load the scene/s that were active when the game was saved.

Would you mind telling is what are you trying to do?

oh, I see. Current I am not trying anything. I just wonder how it works. For example. The player got a level up at a certain scene, then he enter to another scene. How can I keep the player’s data? Should I make the player object as the do not destroy object? Or any other ideas? 


Ah okay. This is something I hope to tackle on the next tutorial. All your scenes that the Player can move around, should have the Player object.

So if your game has 2 scenes (A and B), you'll need to create a Player object on A and another one on B. If you equip your character with a sword on sceneA and then load sceneB, the player on sceneB will automatically equip it when the scene is loaded.

Same happens when loading a game. If the previously saved game had the player's health at 20/100, loading the game will set the player's health to 20/100 on the first frame.

OK I see. It is clear and GC handles that automatically as I create the object with the player component? Is it right?

and how about I have 2 players? Still work in that way?


Yes exactly. The Player is a bit of a special object though, and it automatically saves a lot of information, such as its current inventory, equipment, etc... 

For the Player to save its stats, however, just make sure the ID (the last line of the Stats component) is not a random number. You can modify it and set the ID to something more human-friendly, such as "player". This will tell Game Creator that two Stats component in two different scenes, should be treated as the same.

As for having more than one player, that's unfortunately not supported. I'm working on improving this on our next major iteration, but for the moment, it's not possible,


OK. Thank you for your detail explanation. I think I got enough information form this post.