Hello guys, this is the code where the problem is situated: using UnityEngine;using System.Collections;using System.Collections.Generic; - Pastebin.com
This code works if I just want to instantiate every enemy after a delay specified inside enemyDataSpawn (I didn’t write the “instantiate enemy” part, situated after the yield inside IEnumerator because it’s not important for my problem).
The problem is that i want to create an integer (called maxOnScreen) for every kind of enemy, and if the number of the ACTIVE enemies with the same name is equal to maxOnScreen, then i want to stop to instantiate every other enemy until one enemy (which active number was equal to maxOnScreen) will be deactivated or destroyed. If one enemy is not activated anymore and the number of active enemies with the same name is not equal to maxOnScreen anymore, than I want to instantiate the next enemy in the list again with his delay as my actual code already does. I don’t know how to achieve this with IEnumerator so my question is: is it possible to achieve this with IEnumerator or i should use some other methods?
Thank you in advance.