using System.Collections; using UnityEngine; public class EnemySpawner : MonoBehaviour { [SerializeField] private GameObject enemyPrefab; //적 [SerializeField] private float spawnTime; //적 생성 시간 [SerializeField] private Transform[] wayPoints; //이동경로 private void Awake() { StartCoroutine("SpawnEnemy"); } private IEnumerator SpawnEnemy() { while (true) { GameObject clone = Instantiate(enemyPrefab); Enemy enemy = clone.GetComponent(); enemy.Setup(wayPoints); yield return new WaitForSeconds(spawnTime); } } }