Spawn Points

I am trying to get a enemy named ‘Demon’ to spawn at designated intervals in the map each called ‘spawn’. I am also limiting it to one demon at a time. There is a collider attached to the player called spawner that when it collides with the spawn the demon will appear. Does anyone know how I could put this into code? So far I have this to attach to each spawn:

void OnTriggerEnter(Collider other)
    {
        if(other.tag != "Player")
           return;
 
        GameController handle2otherEnemies= GameObject.FindWithTag("Enemy");
 
        if(handle2otherEnemies!=null)
           return;
        else
          Instantiate(Enemy,transform.position,transform.rotation);
    }

The problem is that it tells me the name space “GameController” does not exist and that “Enemy” does not exist in that context.

GameObject Find returns a GameObject type, If you just need to check if enemy exist you can simply do

GameObject handle2otherEnemies= GameObject.FindWithTag("Enemy");

Multiple issues here.

Do you have a class named GameController? Unity can’t find it.

Do you have a variable called enemy? Unity can’t find it either.

Here is a quick fix. This code will spawn another Enemy only if it there is no existing enemy:

// Assign this via the inspector
public GameObject Enemy;

void OnTriggerEnter(Collider other)
    {
        if(other.tag != "Player")
           return;
 
        GameObject handle2otherEnemies= GameObject.FindWithTag("Enemy");
 
        if(handle2otherEnemies != null)
           return;

        Instantiate(Enemy,transform.position,transform.rotation);
    }