public void Update() { if (times < 30 && flag == 0) { if (interval <= 0) { interval = Random.Range(3, 5); times++; int num = Random.Range(1, 4); for (int i = 0; i < num; i++) { factory.produceUFO(); } } interval -= Time.deltaTime; } }