Android Games Save/Load
I'm developing my android game is there a way how to save and load a game, current position of the player and coins count i'm using Complete Physics Platformer Kit and Mad Level Manager or anyone knows how to do it? like when you press the save button it will save player current position and coin count etc..and if you will exit the game and if you will press load button the game will load
THANKS IN ADVANCE
You can save game state using the PlayerPrefs ,Save Game State in the Scriptable Object or Use server.
Answer by JustinEllis · Apr 10, 2017 at 05:05 PM
Check this out: http://stackoverflow.com/questions/25746380/saving-loading-unity3d
This is the method I use and it works great. Only time problems arise is when you try loading a file when you have saved different information on it. For example saving mana points. Then later you decide not to use mana and try adding something else to save. When you load that on android it messes everything up. A fix is use a different file name.
Answer by Cuttlas-U · Apr 10, 2017 at 05:15 PM
Hi; saving for games is like pressing a button but for us who create the games is not easy like that ;
u should save each variable and load them ;
for example if u want to save the coin amount u should do it like this :
public int coinAmount;
// call this where ever u want to save the coin variable
PlayerPrefs.SetInt("CoinNumber", coinAmount);
then when u want to get it in the next lunch of the game u should do it like this :
void Start()
{
if ( PlayerPrefs.HasKey ("CoinNumber")) // check if we already save It before
{
coinAmount = PlayerPrefs.GetInt("CoinNumber");
}
else
{
coinAmount = 0;
}
}
u should save all of your variables like this and load them again ;
i suggest u to watch some youtube tutorial just search "PlayerPrefs in unity" there are very good tutorial on who to do this ;
Your answer
Follow this Question
Related Questions
WebGl taking too long to load. size is large 1 Answer
Unity UI Dropdown options from folder 2 Answers
unity load in unity. Is it Possible ? 0 Answers
2D player sliding after scene transition 0 Answers