using System.Collections; using System.Collections.Generic; using UnityEngine; public class EnemySpawner : MonoBehaviour { public float delay; public GameObject[] enemyPrefabs; public Transform[] spawnPoints; void Start() { StartCoroutine(SpawnRoutine()); } IEnumerator SpawnRoutine() { while(true) { yield return new WaitForSeconds(delay); int enemyIndex = Random.Range(0, enemyPrefabs.Length); int positionIndex = Random.Range(0, spawnPoints.Length); GameObject newEnemy = Instantiate(enemyPrefabs[enemyIndex], spawnPoints[positionIndex].position, Quaternion.identity, transform); } } }