simple waypoint system enemy wave spawner

I can’t get the enemies (gameObjects) to delete. I’ve tried setting them up to delete if they collided with a preset destroyer box beneath the game screen and I’ve tried to have them destroy themselves if they collide with the player or player bullets. Since my wave spawning was contingent upon the first wave being either destroyed by the player or the GameManager (if they go off screen), I tried another script that looked a bit more promising. But now, I’m stuck on one part of my code that I can’t figure out. Can you help me figure out what I’m doing wrong in this script, so I can set the waves of enemies to continue without overtaxing my CPU?

It’s all between two scripts that I’m trying to accomplish the enemy wave spawner function.
Here’s my WaveSpawner script:

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

public class WaveSpawner : MonoBehaviour
{

public enum SpawnState
{
Spawning,
Waiting,
Counting}

;

[System.Serializable]
public class Wave
{
public string name;
public GameObject enemyGO;
public int count;
public float rate;
}

public Wave waves;
private int nextWave = 0;

public float timeBetweenWaves = 5f;
public float waveCountdown;

public splineMove eMove;

private float searchCountdown = 1f;

private SpawnState state = SpawnState.Counting;

void Start ()
{
waveCountdown = timeBetweenWaves;
}

void Update ()
{
if (state == SpawnState.Waiting) {
//Check if player has killed all enemies
if (!EnemyIsAlive ()) {
//Begin a new wave
Debug.Log(“Wave Complete!”);
return;
} else {
return;
}

  }
  if (waveCountdown <= 0) {
     if (state != SpawnState.Spawning) {

        //Start spawning wave
        StartCoroutine (SpawnWave (waves [nextWave]));
     }
  } else {

     waveCountdown -= Time.deltaTime;
  }

}

bool EnemyIsAlive ()
{
searchCountdown -= Time.deltaTime;
if (searchCountdown <= 0f) {
searchCountdown = 1f;
if (GameObject.FindGameObjectWithTag (“Enemy”) == null) {
return false;
}
}
return true;
}

IEnumerator SpawnWave (Wave _wave)
{
//Spawn
Debug.Log("Spawning Wave: " + _wave.name);
state = SpawnState.Spawning;

  for (int i = 0; i < _wave.count; i++) {
     SpawnEnemy (_wave.enemyGO);
     yield return new WaitForSeconds (1f / _wave.rate);
  }

  state = SpawnState.Waiting;

  yield break;

}

void SpawnEnemy (GameObject _enemy)
{

  string[] myPaths = new string[] { "Path 1", "Path 2", "Path 3", "Path 4", "Path 5" };
  //create reference to Waypoint Manager, specifying which path to use
  PathManager myPath = WaypointManager.Paths["Path 1"];

  Debug.Log ("Spawning Enemy: " + _enemy.name);

  //create a new copy of the _enemy and make it equal to _enemy at the following parameters
  GameObject newEnemy = (GameObject)Instantiate(_enemy, myPath.waypoints[0].position, Quaternion.identity);

  //set eMove to that new copy of _enemy (newEnemy) and get splineMove script to reference its movement path
  eMove = newEnemy.GetComponent<splineMove> ();

  //set the path of eMove to Path 1 of WaypointManager's preset paths
  eMove.SetPath(myPath);

}
}

And here’s my Enemy Script:

using UnityEngine;
using System.Collections;

public class Enemy : MonoBehaviour {

// Use this for initialization
void Start () {

}

// Update is called once per frame
void Update () {
//Get the enemy current position
Vector2 _enemyPos = transform.position;

  //the bottom-left point of the screen
  Vector2 min = Camera.main.ViewportToWorldPoint(new Vector2 (0,0));

  //if enemy went outside the screen on the bottom, then destroy the enemy
  if (_enemyPos.y < min.y) {
     //GameManager.KillEnemy (this);
     Destroy (gameObject);
  }

}

//Made this OnTriggerEnter2D function since the function above wouldn’t destroy the enemy gameObjects
void OnTriggerEnter2D(Collider2D col){
if ((col.tag == “Player”) || (col.tag == “Destroyer”)) {
Destroy (gameObject);
}
}
}

As a backup, I made this Destroyer Script and attached to an empty GameObject with a Box Collider2D that covers the width of the bottom of the screen and is set to IsTrigger. Here it is:

using UnityEngine;
using System.Collections;

public class Destroyer : MonoBehaviour {

void OnTriggerEnter2D(Collider2D col){
if (col.tag == “Enemy”) {
Destroy (gameObject);
}
}
}

None of it is destroying the enemy ships. What am I doing wrong?

Thanks in advance,
Millie

In your Destroyer class, when you say Destroy(gameobject), you are destroying the game object which the Destroyer script is attached to. If you want it to instead destroy the enemies, it should be

Destroy(col.gameObject);