I have a very simple script for my score: it increases by 1 every second and by a specific amount everytime an enemy is destroyed. If the player is touched by an enemy, the player’s game object gets destroyed. How would I stop the score from increasing over time after the player is destroyed?
This is the script for the score:
public class ScoreProgression : MonoBehaviour
{
Text scoreText;
public int enemiesKilledScore;
int totalScore;
void Start()
{
scoreText = GetComponent<Text>();
}
void Update()
{
totalScore = (int)Time.time + enemiesKilledScore;
scoreText.text = totalScore.ToString();
}
}