I’m following a tutorial online and I’ve run into an issue. I’ve checked several times to see ensure I followed the instructions correctly. I’ve checked the comments and even recent comments are complimenting the tutorial without having had the same issue.
bool EnemyIsAlive()
{
//
searchCountdown -= Time.deltaTime;
if (searchCountdown <= 0f)
{
searchCountdown = 1f;
Debug.Log("Searching!");
if (GameObject.FindGameObjectsWithTag("Enemy") == null)
{
Debug.Log("All enemies have been eliminated!");
return false;
}
}
return true;
}
The search countdown is resetting and I’m getting the “Searching!” message just fine but the bool does not return false and the “All enemies have been destroyed” message is not displayed. I’ve double checked that the instantiated objects with the Enemy tag are being destroyed and that there are no other objects in the scene with the tag. is there something wrong with the if statement I’m just not seeing?