Application.LoadLevel FPS AI Eliminate

Hi, I was wondering how I could use the Application.LoadLevel script to load a level after the last AI has been destroyed? I understand how I can use it with specific function, but which to do. I don’t want a WHOLE script, just a line that would let me do this function!

1 Answer

1

not sure what you’re trying to do… but:

class LoadOnDestroy : MonoBehaviour
{
  private static int instanceCount = 0;

  void Start()
  {
    instanceCount ++; 
  }

  void OnDestroy()
  {
    if (--instanceCount == 0)
       LoadLevel(...);
  }
}

would a code something like this work for your purpose?