- Home /
How can I save the player's progress in-game?
I already know how to save particular variables and load them back up, but I plan on making a larger game which would include having to save a large number of variables. With that, is there any way I can save everything that is going on in a scene in only a few lines of code? Back in my GameMaker days, I believe you could save the entire game by typing something like "Game.save();" or something along those lines, is there anything like that in Unity? Or am I stuck with having to save each individual variable?
quick example of what I am looking for would be, the player kills a number of enemies, their bodies stay on the ground, they save their game at a save station, and when they load back they have the same number of ammo and health, the same number of enemies are on the floor and dead, the player keeps whatever they gained from the fight, etc.
Thanks in advance for any advice given.
Answer by Cherno · Jun 28, 2015 at 07:43 PM
is there any way I can save everything that is going on in a scene in only a few lines of code?
Absolutely not. (De)Serialization is a fairly complex topic and required copious amounts of research and trial and error to get it to work with Unity-specific classes like MonoBehaviors and what not. That being said, here is a short introduction to saving and loading data:
http://answers.unity3d.com/questions/967840/saving-your-scene-and-location-in-game.html