- Home /
how to stop the score from adding upon death?
I have a player that get points for avoiding obstacle but when my player dies, the points still adds up. so how do I stop my player from getting points upon death? I tried using time.timescale = 0; it works half way but when i click restart, the game is still paused. so I decided that i should stop the score from adding when player died which i can't figure out how to do so xD. sorry.... i'm new and it's been a while since i started making this first game of mine
this is my Destroy player script:
public GameObject gameOverText;
public GameObject restartButton;
public ScoreManager manager;
// Use this for initialization
void Start ()
{
}
// Update is called once per frame
void Update ()
{
}
void OnTriggerEnter2D(Collider2D other)
{
if (other.gameObject.CompareTag ("Player")) {
Destroy (other.gameObject);
Restart ();
}
}
void Restart()
{
gameOverText.SetActive (true);
restartButton.SetActive (true);
}
}
and this is the scoremanager
public Text scoreText;
private int Points;
// Use this for initialization
public void Start ()
{
Points = 0;
scoreText.text = "score:" + Points;
}
// Update is called once per frame
public void AddPoints(int amount)
{
Points = Points + amount;
scoreText.text = "score:" + Points;
}
}
Comment