UnityScripterAI
Discord ↗
Link Copied to Clipboard
×
"infinite spawn anything"
public class InfiniteSpawn : MonoBehaviour { [SerializeField] GameObject[] obj; [SerializeField] float spawnMin = 1f; [SerializeField] float spawnMax = 2f; void Start() { Spawn(); } void Spawn() { GameObject instance = (GameObject)Instantiate(obj[Random.Range(0, obj.GetLength(0))], transform.position, Quaternion.identity); instance.transform.parent = this.transform; Invoke("Spawn", Random.Range(spawnMin, spawnMax)); } }