- Home /
Save Game - What do I need?
I know this question is asked a lot. I've seen numerous posts asking how to make a Save Game function and they're always answered with "Its complicated (blah blah) no single answer (blah blah)."
What I'm asking is: what are the basic components (like Serialization, arrays, etc.) of a simple Save/Load feature?
That way, you can tell me WHAT I need and I can go learn it myself. So, please, don't answer with "It's complicated and it would take too long to explain" because I've heard it a thousand times.
Answer by Slobdell · Jun 14, 2013 at 12:10 AM
Only you can answer that question. When you load the scene, what is it's state? When you save the game, what is it's state? Save the difference. You just have to save all possible things in the scene/game state that can be changed(level, health, object positions, time, etc. , so that you can bring your game from start state to current state when loading, or last save to now.
I think you misunderstood my question (though your answer did provide a little extra insight to what a save feature really does).
What are some ways of saving that information so it may be called upon later? That's why I asked about serialization because I've seen that word come up a few times and will be looking further into that once I clean up the bugs in my other scripts.
What you need to serialize depends on your game. Some games just need the score and the level number/name, others need to reposition enemies and have them in the current state that they were when it was saved etc etc
You can save simple data to PlayerPrefs, a file using JSON/X$$anonymous$$L/Plain text with ease (level name, number). You can also store such information on a server if you have a way of creating one (ftp for server files, PHP perhaps for a database and an endless list of other choices).
Anything further than that requires you to create a structure of the information for saving. Unity Serializer offers one such way of creating that structure for you as it saves the data from just everything you flag as important to a byte[] or a string of JSON that can be stored in PlayerPrefs, a file or on a server.
The biggest complexity in serialization is recreating the links to assets in the game, which means that games that change the assets in use, or change the references to other game objects (like specifying the target that is being followed by an enemy etc) are much harder to do as Unity doesn't have a persistent identifier that can be used to find these things. Again, that's something the Unity Serializer does.
ok, so, basically, serialization. Got it. I'll look into that then. Thanks guys.
Also, my game isn't going to be that incredibly complex (I think) so creating the links to my data shouldn't be that much of a problem.
Your answer
Follow this Question
Related Questions
How to store a boolean for each variable in a class 1 Answer
load button in main menu 1 Answer
Save/Load Game and buttons New Game/Load Game? 1 Answer
Save/Load/New 1 Answer
Problem Saving game progress 1 Answer