Hello all. In my scene there is a timer that counts down from 60 seconds. (not a coroutine just a visible timer). When it reaches “0”, I want a function to get all the gameobjects that are in the scene tagged as “Enemy” AND if there are 10 or less, DESTROY them all, BUT if there are 11 or more, do something else (stop the game etc.) I cant seem to get this to work properly and it doesn’t seem like it should be that sophisticated. Thank you in advance and im using C#.
if (timer <= 0)
{
GameObject foundObjects = GameObject.FindGameObjectsWithTag(“Enemy”); // NOTE: only ACTIVE gameObjects will be found
if (foundObjects.Length < 10){
foreach (GameObject go in foundObjects)
{
Destroy(go);
}
}
else
{
//do something else (stop the game etc.)
}
}