CS0246

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class EnemySpawnController : MonoBehaviour
{
    public int initialEnemiesPerWave = 5;
    public int currentEnemyPerWave;

    //delay between enemies in a wave
    public float spawnDelay = 0.5f;

    public int currentWave = 0;
    //delay between waves
    public float waveCoolDown = 12f;

    public bool inCoolDown;
    //we only use this for testing
    public float cooldownCounter = 0;

    public List<Enemy> currentEnemiesAlive;
   
    public GameObject enemyPrefab;

    public void Start()
    {
        currentEnemyPerWave = initialEnemiesPerWave;

        StartNextWave();
    }

    private void StartNextWave()
    {
        currentEnemiesAlive.Clear();

        currentWave++;
       
        StartCoroutine(SpawWave());
    }

    private IEnumerator SpawnWave()
    {
        for (int i =0; i < currentEnemyPerWave; i++)
        {
            //generate a random offset within a range
            Vector3 spawnOffset = new Vector3(Random.Range(-1f,1f), 0f, Random.Range(-1f, 1f));
            Vector3 spawnDelayPosition = transform.position + spawnOffset;

            //instantiate the enemy
            var enemy = Instantiate(enemyPrefab, spawnPosition, Quaternion.identity);

            //get enemy Script
            EnemyAI enemyScript = enemy.GetComponent<EnemyAI>();

            //track enemy
            currentEnemiesAlive.Add(enemyScript);

            yield return new WaitForSeconds(spawnDelay);


        }
    }

    private void Update()
    {
        List<Enemy> enemyToRemove = new List<Enemy>();
        foreach (Enemy enemy in currentEnemiesAlive)
        {
            if (enemy.isDead)
            {
                enemyToRemove.Add(enemy);
            }
        }

        // actually remove all dead enemies
        foreach (Enemy enemy in enemyToRemove)
        {
            currentEnemiesAlive.Remove(enemy);
        }

        enemyToRemove.Clear();

        //start cooldown if all enemies are dead
        if (currentEnemiesAlive.Count == 0 && inCoolDown == false)
        {
            //start cooldown for next wave
            StartCoroutine(waveCoolDown());
        }

        //run cooldown counter
        if (inCoolDown)
        {
            cooldownCounter -=Time.deltaTime;
        }
        else
        {
            cooldownCounter = waveCoolDown;
        }
    }

    private IEnumerator WaveCoolDown()
    {
        inCoolDown = true;

        yield return new WaitForSeconds(waveCoolDown);

        inCoolDown = false;

        currentEnemyPerWave *= 2;
        StartNextWave();
    }

}

Is there anything wrong with this code? I have been stuck :expressionless:

Assets\Scripts\EnemySpawnController.cs(21,17): error CS0246: The type or namespace name ‘Enemy’ could not be found (are you missing a using directive or an assembly reference?)

It’s saying at line 21 starting with character 17 it doesn’t recognize Enemy. Is there a class or struct with that name in your project?

No class.

You need either a class or struct. The name you put in the < and > is the name of a class or struct that will be used as the type of the List.