I have to keep spawning enemies after the main enemy dies, here is the code `
using System.Collections;
using UnityEngine;
using UnityEngine.UI;
public class WaveSpawner : MonoBehaviour
{
public Transform enemyPrefab;
public Transform SpawnPoint;
public float TimeBetweenWaves = 6.5f;
private float countdown = 3f;
public Text waveCountdownText;
private int WaveIndex = 0;
void Update()
{
if (countdown <= 0f)
{
StartCoroutine(SpawnWave());
countdown = TimeBetweenWaves;
}
countdown -= Time.deltaTime;
waveCountdownText.text = Mathf.Round(countdown).ToString();
}
IEnumerator SpawnWave()
{
WaveIndex++;
for (int i = 0; i < WaveIndex; i++)
{
SpawnEnemy();
yield return new WaitForSeconds(0.7f);
}
}
void SpawnEnemy()
{
Instantiate(enemyPrefab, SpawnPoint.position, SpawnPoint.rotation);
}
}
`