Hi, Im making a game where I want, in the first wave for 10 enemies to spawn (Get activated) as the game starts, and then 20 more after 5 minutes has gone by. I’ve tried to figure it out, and was unsuccessful. Any help would be awesome!
function Start()
{
gameObject.SetActive(false);
}
function Update () {
if (Time.time > 300)
{
gameObject.SetActive(true);
}
}
When you disable a game object, you no longer receive Update() calls. So any solution that uses Update() will fail. One solution is to use a boolean flag rather than disabling the game object. But if you must disable the game object, Invoke() still works with disabled game objects. You can do:
function Start() {
Invoke("Reenable", 300);
gameObject.SetActive(false);
}
function Reenable() {
gameObject.SetActive(true);
}