- Home /
Save and Load
I'm am trying to make a Save and Load system for my game.
I want it to work like this their are up to three slot you can save. In your Menu you can Load your game file.
[Slot 1]
[Slot 2]
[Slot 3]
Like a Rpg Game.
By the way I want the Save file to be save on to the computer. And How can I Make it so if I every update the game the player will keep their save file.
Plz Help.
I was thinking about the Save and load and has some more questions.
(1) How can you save Static Variables?
(2) What code do you need to save the game? and what do it save?
(3) How do Load a save file?
(4) Where do the file go on your computer?
(5) Save the Player Position and Object that been create like (Building, Loot, $$anonymous$$onsters that you kill)
You should watch the training video on data persistence. It answers literally every question you have listed here in a lot better detail than any of us can provide with just a written solution. The only question it doesn't describe explicitly is your question on static variables but they are handled the same way as any other variable as long as you have visibility to them. And I believe that once you understand the basics you will understand how to do static variables too.
Answer by A3tra3rpi · Jul 22, 2014 at 06:34 PM
Take look at unity serializer http://u3d.as/content/ixion-software/save-game-json-binary/33x. it has same kind of saving slot system as you descriped. I'm not sure if serializer files can be untouched on updating your game. It depends on your updater.
Answer by zharik86 · Jul 22, 2014 at 06:33 PM
The most simple and fast way, it to use PlayerPrefs. And also look at PlayerPrefsX addition here according to this link:
private Vector3 myPos = Vector3.zero;
//Function of data loading using slot number
public static void LoadDataFromSlot(int tpSl) {
//See correct of slot how string Slot1_PlayerPosition and etc
string nameSlot = "Slot" + tpSl.toString() + "_";
//For example position of your character, how Vector3
myPos = PlayerPrefsX.GetVector3 (nameSlot +"PlayerPosition", Vector3(100, 50, 0));
...
}
public static void SaveDataToSlot(int TpSl) {
//See correct of slot how string Slot1_PlayerPosition and etc
string nameSlot = "Slot" + tpSl.toString() + "_";
//For example, save position
PlayerPrefsX.SetVector3(nameSlot + "PlayerPosition", myPos);
...
}
I hope it will help you.
@epicking220 I would save as well as would load them, but wouldn't do variables static. It is better to make static functions of saving/loading. At the very beginning of development of use of PlayerPrefs the best. Further already, when everything is ready if to you not to be pleasant to PlayerPrefs, it is possible to write the script for loading/saving. I added the response.
Your answer
Follow this Question
Related Questions
Save and Load Questions 0 Answers
Saving/Load using menu C# 1 Answer
Loading a list into unity 0 Answers
PlayerPrefs 2 Answers
PlayerPrefs don't load again after Android game closes for the first time. 1 Answer