Forum begins after the advertisement:
-
Lê Former Patron
::I have 5 round enemies but when round 1 ends it always jumps to round 5 and skips round 2-3-4
View post on imgur.com
Lê Former Patron
::It is not working with me. but I’ve fixed that by adding Boolean
<code>
private bool newWave = false;
int currentWaveQuota = 0;
void Update()
{
if (!waveStarted && currentWaveCount < waves.Count && waves[currentWaveCount].waveQuota == currentWaveQuota)
{
StartCoroutine(BeginNextWave());
newWave = true;
}
spawnTimer += Time.deltaTime;
//Check if it's time to spawn the next enemy
if (spawnTimer >= waves[currentWaveCount].spawnInterval)
{
spawnTimer = 0f;
SpawnEnemies();
}
}
IEnumerator BeginNextWave()
{
yield return new WaitForSeconds(waveInterval);
if (currentWaveCount < waves.Count - 1)
{
currentWaveCount++;
CalculateWaveQuota();
newWave = false;
}
}
}
void CalculateWaveQuota()
{
int currentWaveQuota = 0; => Delete this
foreach (var enemyGroup in waves[currentWaveCount].enemyGroups)
{
currentWaveQuota += enemyGroup.enemyCount;
}
waves[currentWaveCount].waveQuota = currentWaveQuota;
//Debug.LogWarning(currentWaveQuota);
}
</code>
::Glad you managed to fix this!
Advertisement below: