Hi, recently I’ve started making a 2d game in which the player is supossed to kill all the enemies on a level, then a panel stating that you finished the level pops up and after clicking the “Next level” button, well, it takes you to the next level. My problem is, while I do know how to make the panel with button itself, I don’t really know how to make the panel appear after all the enemies are killed. So my question is, how to make this happen?
You make a count of all enemies. You can make it dynamic too. You will need a singleton or scriptable object that keeps track of all the enemies. This is easy to do on your enemy script, I’ll assume you have a game manager singleton you can use, on your enemy script have:
OnEnable()
{
GameManager.Instance.enemyCount++;
}
OnDisable()
{
GameManager.Instance.enemyCount--;
}
Then in your GameManager you have:
public void enemyCount=0;
public void CheckEnemyCount()
{
if(enemyCount<1)
{
//show your thing
}
}