#How to Create a Counter that increases when something dies?
1 messages · Page 1 of 1 (latest)
-
In your scene manager script add a condition(counter var) to the
sceneManager.LoadScene(yourSceneName)
All of the code must be put in the update fnc -
Access the counter variable from the scene manager script and add an
counter ++before calling Die()
There are multiple ways to handle that. You could have a LevelManager or GameManager and on death accessing a function inside them to keep track of the deaths.
gameManager.Died();
and inside the GameManager script
public float enemiesInLevel;
public void Died(){
enemiesInLevel--;
if(enemiesInLevel <= 0){
ChangeLevel();
}
}
Or you could add onto a death counter and end the level after a specific number.