Hello there, I’m making an incremental game that can be played on android. I’ve tried a couple of time’s to make it work so it saves my game everytime i close it and when i open it again every stats are still there. But i can’t get it to work.
Here’s a video of the game so far, i would like to save how much gold i have, how much gold per/click , how much gold per second, and what level the items are so you won’t need to buy it over and over again every time you play the game and quit the game.
You also need to specify an amount, currently you are only specifying a name.
Do keep in mind though, that PlayerPrefs is NOT recommended to use to save anything that should not be editable by the user outside of the game as playerprefs saves a cleartext file. If you do not want your players to be able to edit the file easily, I suggest looking into serializing your data. More info in this live training VOD: http://unity3d.com/learn/tutorials/modules/beginner/live-training-archive/persistence-data-saving-loading
When you set the playerpref int it needs two parameters, the Internet name & the value. Yours should probably be:
PlayerPrefs.SetInt(“GoldAmount”,gold)
Where gold is the int you defined at the top of your script. You should also probably call your script something else as it is a reserved namespace so might be causing the issue you have as it could be getting confused between your script & the actual Unity playerprefs.
The sample code provided above needs you to call the save function. If you are just trying to get it to save without the player hitting a save button then every time something changes you will need to set the player prefs & also save the player prefs. I have no PC atm but I think there is something like PlayerPrefs.Save as well that you need to use.
i just can’t get it to work , i’m giving up , maybe i’m not experienced enough maybe its because i’m just 13 , but i don’t now how to get it to work , but thank everyonne for trying to help me out