On lesson 138. I’ve created a Spawner prefab and the code. I’m not sure why, but it’s not spawning any enemies. I’m sure it’s a simple mistake that I’m overlooking, so maybe a second set of eyes will help me. No errors are being thrown in the console
My EnemySpawner.cs file
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class EnemySpawner : MonoBehaviour
{
bool spawn = true;
[SerializeField] float minSpawnDelay = 1f;
[SerializeField] float maxSpawnDelay = 5f;
[SerializeField] Enemy enemyPrefab;
// Start is called before the first frame update
IEnumerable Start()
{
while (spawn) {
yield return new WaitForSeconds(Random.Range(minSpawnDelay, maxSpawnDelay));
SpawnEnemy();
}
}
private void SpawnEnemy() {
Instantiate(enemyPrefab, transform.position, transform.rotation);
}
// Update is called once per frame
void Update()
{
}
}