Trying to make 2 Spawn Points for a TD Game, but odd things are happening...

Okay, so I’m attempting to make a 2-Lane scene within my Tower Defense game, I’ve set up 2 lots of Waypoints, each with their own script. I’m thinking of also 3-Lane and 4-Lane versions too… But so far I have come into a rather annoying snag,

Waypoint

using UnityEngine;

public class Waypoints : MonoBehaviour
{
    public static Transform[] points;

    void Awake ()
    {
        points = new Transform[transform.childCount];
        for (int o = 0; o < points.Length; o++)
        {
            points[o] = transform.GetChild (o);
        }
    }

}

Waypoint_2ndLane

using UnityEngine;

public class Waypoints_2ndLane : MonoBehaviour
{
    public static Transform[] points2;

    void Awake ()
    {
        points2 = new Transform[transform.childCount];
        for (int i = 0; i < points2.Length; i++)
        {
            points2[i] = transform.GetChild (i);
        }
    }

}

Plus I have also created a 2nd Lane EnemyMovement script too, so I have 2 seperate enemy prefabs, one with ‘EnemyMovement’ and one with ‘EnemyMovement 2Lane’.

EnemyMovement

using UnityEngine;
using System.Collections;

[RequireComponent(typeof(Enemy))]
public class EnemyMovement : MonoBehaviour {

    private Transform target;
    private int wavepointIndex = 0;

    private Enemy enemy;

    void Start ()
    {
        enemy = GetComponent<Enemy> ();
        target = Waypoints.points[0];
    }

    void Update ()
    {
        Vector3 dir = target.position - transform.position;
        transform.Translate(dir.normalized * enemy.speed * Time.deltaTime, Space.World);

        if (Vector3.Distance (transform.position, target.position) <= 0.2f)
        {
            GetNextWaypoint ();
        }

        enemy.speed = enemy.startSpeed;
    }

    void GetNextWaypoint()
    {
        if (wavepointIndex >= Waypoints.points.Length - 1)
        {
            EndPath ();
            return;
        }
        wavepointIndex++;
        target = Waypoints.points [wavepointIndex];
    }

    void EndPath()
    {
        PlayerStats.Lives--;
        WaveSpawner.EnemiesAlive--;
        Destroy (gameObject);
        if (WaveSpawner.EnemiesAlive == 0) {
            PlayerStats.Money += 10;
        }
    }
}

EnemyMovement_2Lane

using UnityEngine;
using System.Collections;

public class EnemyMovement_2Lane : MonoBehaviour {
   
    private Transform target2;
    private int wavepointIndex = 0;

    private Enemy enemy2;

    void Start ()
    {
        enemy2 = GetComponent<Enemy> ();
        target2 = Waypoints_2ndLane.points2[0];
    }

    void Update ()
    {
        Vector3 dir = target2.position - transform.position;
        transform.Translate (dir.normalized * enemy2.speed * Time.deltaTime, Space.World);
        if (Vector3.Distance (transform.position, target2.position) <= 0.2f)
        {
            GetNextWaypoint2 ();
        }
        enemy2.speed = enemy2.startSpeed;
    }
    void GetNextWaypoint2()
    {
        if (wavepointIndex >= Waypoints_2ndLane.points2.Length - 1)
        {
            EndPath ();
            return;
        }
        wavepointIndex++;
        target2 = Waypoints_2ndLane.points2 [wavepointIndex];
    }

    void EndPath()
    {
        PlayerStats.Lives--;
        WaveSpawner.EnemiesAlive--;
        Destroy (gameObject);
        if (WaveSpawner.EnemiesAlive == 0) {
            PlayerStats.Money += 10;
        }
    }
}

The final bit of coding is the spawning of the waves, I’ve set the 2 spawn points, and they spawn there fine… So I don’t suspect that it’s the spawner causing this…
WaveSpawner

using UnityEngine;
using System.Collections;
using UnityEngine.UI;

public class WaveSpawner : MonoBehaviour {
    public static int EnemiesAlive = 0;
    public Wave[] waves;
    public Transform[] spawnPoint;
    public float timeBetweenWaves = 20f;
    private float countdown = 10f;
    private int waveIndex = 0;
    public Text waveCountdownText;

    void Start ()
    {
        EnemiesAlive = 0;

    }
    void Update()
    {
        if (EnemiesAlive > 0)
        {
            return;
        }
        if (countdown <= 0f)
        {
            StartCoroutine (SpawnWave());
            countdown = timeBetweenWaves;
            return;
        }
        countdown -= Time.deltaTime;
        countdown = Mathf.Clamp (countdown, 0f, Mathf.Infinity);

        waveCountdownText.text = string.Format("Wave " + (waveIndex + 1) + " in {00:00}", countdown);
    }

    IEnumerator SpawnWave()
    {       
        PlayerStats.Rounds++;
        Wave wave = waves [waveIndex];
        for (int i = 0; i < wave.count; i++)
        {
            SpawnEnemy(wave.enemy);
            SpawnEnemy2(wave.enemy);
            yield return new WaitForSeconds(1f / wave.rate);
        }
        waveIndex++;
        if (waveIndex == waves.Length) {
            Debug.Log ("Level Won!");
            this.enabled = false;
        }
    }

    void SpawnEnemy(GameObject enemy)
    {
        Instantiate (enemy, spawnPoint [0].position, spawnPoint [0].rotation);
        EnemiesAlive++;
    }
    void SpawnEnemy2(GameObject enemy)
    {
        Instantiate (enemy, spawnPoint [1].position, spawnPoint [1].rotation);
        EnemiesAlive++;
    }
   
}

The final result is this…

Hopefully someone may be able to assist me on this…

You say that you have two separate enemy prefabs, but yet you seem to be using only one type

            SpawnEnemy(wave.enemy);
            SpawnEnemy2(wave.enemy);

Shouldn’t one of them spawn the second type of enemy prefab?

That is true… I am using 2 Seperate spawners in the Game, that must mean I’d need 2 seperate WaveSpawner scripts, one for each spawner?

Either that or have something like wave.enemy1 and wave.enemy2.

Thank you so much! I decided I needed to create a separate wavespawner depending on how many lanes were in that scene. plus I turned the enemy into an Array, so I can easily add more enemies depending on the lane requirements…