Not a problem, was just curious about some console output from a bit of code

why does the console out put say, 28,29,30 and not just 30?? … while I’m posting is there any better way to get the same result but with a different approach? I heard calling coroutine is bad ideal for the update method.

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

public class BaseController : MonoBehaviour
{
    GameObject minion;
    float waveTimer = 0f; //  timer that tells base when to spawn enemies.
    float spawnDelay = .5f; // delay between each enemy spawn.
    float waveDelay = 60f; // delay between each wave.
    int numberToSpawn = 10;
    int enemyCount = 0;
    List<Transform> spawnPoints = new List<Transform>();


    private void Awake()
    {
        spawnPoints.Add(transform.Find("BaseSpawn1"));
        spawnPoints.Add(transform.Find("BaseSpawn2"));
        spawnPoints.Add(transform.Find("BaseSpawn3"));
        minion = Resources.Load("Prefabs/Enemy/Minion") as GameObject;
    }

    private void Update()
    {
        if(Time.time >= waveTimer)
        {
            for (int i = 0; i < spawnPoints.Count; i++)
            {
                StartCoroutine(SpawnMinion(spawnPoints[i])); // Starts 1 coroutine for each spawn point              
            }
            waveTimer = Time.time + waveDelay;         
        }
    }

    IEnumerator SpawnMinion(Transform spawnPoint)
    {
        for (int i = 0; i < numberToSpawn; i++)
        {
            Instantiate(minion, spawnPoint.position, Quaternion.Euler(0, 0, 0));
            yield return new WaitForSeconds(spawnDelay); // yields this coroutine for spawnDelay game time
            enemyCount++;
        }
        print(enemyCount);
    }
}

you have 3 coroutines running from line 30. thats why you have 3 prints.

you can use this code to take the coroutines out of the update

using UnityEngine;
using System.Collections.Generic;
using System.Collections;
public class BaseController : MonoBehaviour
{
    GameObject minion;
    float waveTimer = 0f; //  timer that tells base when to spawn enemies.
    float spawnDelay = .5f; // delay between each enemy spawn.
    float waveDelay = 60f; // delay between each wave.
    int numberToSpawn = 10;
    int enemyCount = 0;
    List<Transform> spawnPoints = new List<Transform>();
    private bool spawnNextWave = true;
    private void Awake()
    {
        spawnPoints.Add(transform.Find("BaseSpawn1"));
        spawnPoints.Add(transform.Find("BaseSpawn2"));
        spawnPoints.Add(transform.Find("BaseSpawn3"));
        minion = Resources.Load("Prefabs/Enemy/Minion") as GameObject;
    }
    private void Update()
    {
        if(Time.time >= waveTimer)
        {
            spawnNextWave = true;
        }
   
        if(spawnNextWave)
        {
            spawnNextWave = false;
            SpawnWave();
        }
    }
   
    priave void SpawnWave()
    {
        for (int i = 0; i < spawnPoints.Count; i++)
        {
            StartCoroutine(SpawnMinion(spawnPoints[i])); // Starts 1 coroutine for each spawn point             
        }
        waveTimer = Time.time + waveDelay;
   
    }
    IEnumerator SpawnMinion(Transform spawnPoint)
    {
        for (int i = 0; i < numberToSpawn; i++)
        {
            Instantiate(minion, spawnPoint.position, Quaternion.Euler(0, 0, 0));
            yield return new WaitForSeconds(spawnDelay); // yields this coroutine for spawnDelay game time
            enemyCount++;
        }
        print(enemyCount);
    }
}

you should also look into InvokeRepeating(), this would get it completely out of the update.

InvokeRepeating(“SpawnWave”,0f,5f);

Thanks for the input, ill try the example out johne5. I thought about invokerepeating, but at the time without the example above, I was having to pass a param in and invoke doesn’t allow that to my knowledge.