# [Solved]Wave of enemies function

Im trying to make a wave function that increases the amount of enemies that spawn as the waves get harder. I have 2 groups of enemies, scouts and fighters and they are all spawning at the same time but i want to split them up.

``````	void Wave(){

float diffScale = wave/10;
diffScale = Mathf.Clamp(diffScale,0,0.5f);
float healthScale = wave / 20;
healthScale = Mathf.Clamp(healthScale,1,2);

int scouts = 1;
int fighters = 1;
print(scouts + " " + fighters);

for(int i = 0; i < enemies.Count; i++){

if(enemies*.name.Contains("Scout")){*
``````

_ GameObject scout = (GameObject)enemies*;*_

* for(int x = 0; x < scouts; x++){*

* if(!scout.activeInHierarchy){*

* float maxHealth = scout.GetComponent().maxHealth;*
_ scout.GetComponent().health = maxHealth * healthScale;_
* scout.SetActive(true);*
* }*
* }*
* }*
* }*

* for(int i = 0; i < enemies.Count; i++){*

_ if(enemies*.name.Contains(“Fighter”)){*_

_ GameObject fighter = (GameObject)enemies*;*_

* for(int x = 0; x < fighters; x++){*

* if(!fighter.activeInHierarchy){*

* float maxHealth = fighter.GetComponent().maxHealth;*
_ fighter.GetComponent().health = maxHealth * healthScale;_

* fighter.SetActive(true);*
* }*
* }*
* }*
* }*

* wave += 1;*
* }*
What am i doing wrong?

Assuming you want to wait 1 second between each one →

``````IEnumerator waitSetActive(GameObject e, float wait) {
yield return new WaitForSeconds(wait);
e.SetActive(true);
}

..
..
..
//scout.SetActive(true);  change..

StartCoroutine(waitSetActive(scout, i));
``````