Add a death counter (Number of time the player dies)
I'm trying to make a 2D platformer where the player has 3 lives. When the player loses all his lives, it's game over. When he finally completes the level, I want the "Level Done" screen to show how many times the player died in this exact level. So, I want to count how many times the level loads. This is what I have right now but, the counter resets everytime.
public class TriesToComplete : MonoBehaviour {
public int DeathCount;
// Use this for initialization
public void Awake () {
PlayerPrefs.SetInt("DeathCount", DeathCount + 1);
}
}
I have another script that takes this int and makes it a text and it works. Only this is the problem, the int variable is always 0 because of this script. I have also tried
PlayerPrefs.SetInt("DeathCount", PlayerPrefs.GetInt("DeathCount" + 1));
with no good results.
Your answer
Follow this Question
Related Questions
Why my playerPrefs doesen't work 0 Answers
Can PlayerPrefs be accessed in different scripts - c# 2 Answers
How to automatically generate a new int with a specific name? 1 Answer
How to save SetActive states 0 Answers
Playerpref Saving Lag 1 Answer