Skip to content

Instantly share code, notes, and snippets.

@kihira
Created October 26, 2015 21:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kihira/368008c6920f11c7309e to your computer and use it in GitHub Desktop.
Save kihira/368008c6920f11c7309e to your computer and use it in GitHub Desktop.
public List<GameObject> enemyFormations = new List<GameObject>(0);
void Update ()
{
// If we have no enemies on the screen, get a random prefab from our list and spawn it then ensure it is active
if (GameObject.FindGameObjectsWithTag("Enemy").Length <= 0)
{
GameObject prefab = enemyFormations[Random.Range(0, enemyFormations.Count)];
GameObject formation = Instantiate(prefab);
formation.SetActive(true);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment