Anybody know how can i stop cloning object when the game finish / times up ?
I'am using InvokeRepeating to clone object, this is the script :
using UnityEngine;
using System.Collections;
public class SpawnerScript : MonoBehaviour {
public float spawnTime = 5f;
public float spawnDelay = 3f;
public GameObject[] myPrefab;
void Start () {
InvokeRepeating ("Spawn", spawnDelay, spawnTime);
}
void Spawn() {
// Instantiate a random prefab
int notPrefabIndex = Random.Range (0, myPrefab.Length);
Instantiate (myPrefab [notPrefabIndex], transform.position, transform.rotation);
}
}
Thanks before..
↧