Cloning one prefab
I'm making a game but when I Instantiate an object it makes more than one and continues.
The script is
public GameObject boss;
public Text enemiesUI;
public int enemiesLeft;
public void updateEnemies() {
enemiesUI.text = "Enemies: " + enemiesLeft;
}
// Use this for initialization
void Start () {
enemiesLeft = GameObject.FindGameObjectsWithTag ("enemy").Length;
updateEnemies ();
}
// Update is called once per frame
void Update () {
if (enemiesLeft <= 0) {
Instantiate (boss);
}
}
}
How would I fix it?
Comment