I have a script where the scene goes to the next scene when all enemies have died.
using UnityEngine;
using System.Collections;
using UnityEngine.SceneManagement;
public class Enemy : MonoBehaviour
{
// Number of enemies alive
private static int aliveCounter = 14;
void Start()
{
aliveCounter++;
}
void OnKilled()
{
aliveCounter--;
if (aliveCounter == 0)
SceneManager.LoadScene("Lv.02");
}
}
But some of them don't die and fall through the game world which means the player can never advance. Rather that go on some massive collider hunt I'd rather just kill those enemies who fall through the world. Any idea what code I can attach to this script to make that happen?
Thanks!
↧