how can I add a maximum of enemies to be generated for each wave?
using UnityEngine;
using System.Collections;
public class SpawnManager : MonoBehaviour
{
public GameObject hazard;
public Transform spawnPosition;
public int hazardCount;
public float spawnWait;
public float startWait;
public float waveWait;
void Start ()
{
StartCoroutine (SpawnWaves ());
}
IEnumerator SpawnWaves ()
{
yield return new WaitForSeconds (startWait);
while (true)
{
for (int i = 0; i < hazardCount; i++)
{
Instantiate (hazard, spawnPosition);
yield return new WaitForSeconds (spawnWait);
}
yield return new WaitForSeconds (waveWait);
}
}
}
Comment
Your answer
![](https://koobas.hobune.stream/wayback/20220612164714im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
question about object pooling an array and spawning 0 Answers
how to change material on an object in unity 5 0 Answers
Changing Graphic Levels Causing Crash 1 Answer
error CS0103: The name `collidedwith' does not exist in the current context 1 Answer
How can i simulate entering/exit a spaceship logic ? 0 Answers