//Jimmy Vegas Unity 5 Tutorial //This script will spawn your zombies using UnityEngine.UI; public class ZombieSpawner : MonoBehaviour { public int ZombieCount; public int ZombieLimit = 10; public int Interval = 5; public GameObject ZombiePrefab; public GameObject ZombieUI; public int TheTrigger; public int ZombieChoose; void Update () { if (TheTrigger == 0) { StartCoroutine(SpawnZombie()); } } IEnumerator SpawnZombie () { if (ZombieCount <= ZombieLimit) { TheTrigger = 1; ZombieCount += 1; ZombieUI.GetComponent().text = "Zombies Spawned: " + ZombieCount; ZombieChoose = Random.Range (1, 3); if (ZombieChoose == 1) { Instantiate (ZombiePrefab, new Vector3 (-8.8f, 1.6295f, -2.4f), Quaternion.identity); } else { Instantiate (ZombiePrefab, new Vector3 (-8.8f, 1.6295f, 2.6f), Quaternion.identity); } yield return new WaitForSeconds (Interval); TheTrigger = 0; } } }