Question by 
               garciajames458 · Aug 23, 2020 at 09:00 PM · 
                enemiesspawnpoints  
              
 
              2 waypoint and spawnpoint but the problem is enemies not all die and WinLevel just pop out. if 1 is okey. im new here pls help
using UnityEngine; using System.Collections; using UnityEngine.UI;
public class WaveSpawner2 : MonoBehaviour {
 public static int EnemiesAlive = 0;
 public Wave2[] waves;
 public Transform spawnPoint2;
 public float timeBetweenWaves = 5f;
 public float countdown = 2f;
 public Text waveCountdownText;
 public GameManager gameManager;
 private int waveIndex = 0;
 void Update()
 {
     if (EnemiesAlive > 0)
     {
         return;
     }
     if (waveIndex == waves.Length)
     {
             gameManager.WinLevel();
             this.enabled = false;
     }
     if (countdown <= 0f)
     {
         StartCoroutine(SpawnWave2());
         countdown = timeBetweenWaves;
         return;
     }
     countdown -= Time.deltaTime;
     countdown = Mathf.Clamp(countdown, 0f, Mathf.Infinity);
     waveCountdownText.text = string.Format("{0:00.00}", countdown);
     return;
 }
 IEnumerator SpawnWave2()
 {
     PlayerStats.Rounds++;
     Wave2 wave = waves[waveIndex];
     EnemiesAlive = wave.count;
     for (int i = 0; i < wave.count; i++)
     {
         SpawnEnemy2(wave.enemy);
         yield return new WaitForSeconds(2f / wave.rate);
     }
     waveIndex++;
     
 }
 void SpawnEnemy2(GameObject enemy)
 {
     Instantiate(enemy, spawnPoint2.position, spawnPoint2.rotation);
 }
 
               }
               Comment
              
 
               
              Your answer