I’m trying to translate a spawner code into c# but I keep getting errors.
function spawnMinion () {
for (var x = 1; x < 8; x++) {
yield WaitForSeconds(0.2);
Instantiate(minionPrefab,node1.transform.position,node1.transform.rotation);
if(x == 7 ) {
yield WaitForSeconds(5);
x -= 8;
}
}
}
I tried this but it doesn’t want to work
void Awake ()
{
StartCoroutine(Spawn());
wave = GameObject.Find("Wave").GetComponent<Wave>();
}
public IEnumerator Spawn()
{
int enemyIndex = Random.Range (0, enemies.Length);
for (var x = 1; x < 8; x++) {
yield return new WaitForSeconds (0.2);
Instantiate (enemies [enemyIndex], transform.position, transform.rotation);
if (x == 7) {
yield return new WaitForSeconds (5);
x -= 8;
Wave.wavenumber += 1;
}
}
}
Can anyone help me translate the first code into c#?