How do I save my coins with PlayerPrefs?
Hi, I'm working on a 2d endless runner game in Unity and I want to save my coins. When you start the game for the first time you have 0 coins, but when you keep playing your coin amount should be getting more and more. When you quit the game and open it again a day later, your coins should be the same. Like when I play a game and collect 30 coins, play another and get 20. I want to see the 30 go up in the game and store it all so it can only change when you would buy something, haven't made the shop yet tho. I have searched far, but can't really find a anwser. I'm also very new to this. This is my coinspickup/deleting script:
And this is the script I have to keep score:
So I have no idea how to fix this error: There is no argument given that corresponds to the required formal parameter 'value' of 'PlayerPrefs.SetInt(string,int)'.
Like I said I'm very new to this and don't know much about code, pls help. Thank you in advance.
Answer by xxmariofer · Nov 17, 2020 at 01:30 PM
change to
PlayerPrefs.SetInt("CointAmount", PlayerPrefs.GetInt("CoinAmount")+cointAmount);
Your answer
Follow this Question
Related Questions
my coins wont save when collected (USING PLAYERPREFS) 1 Answer
Coin Spending/PlayerPref Subtracting 0 Answers
Problem with coin script and operands 1 Answer
how do i store highscore locally C# (SIMPLE) 3 Answers
PlayerPrefs help ! 1 Answer