Hello I am following this tutorial for Wave Spawning in my game: [link text][1]
[1]: How to make a Wave Spawner in Unity 5 - Part 1/2 - YouTube
I did everything as is done in the tutorial and for some reason I am getting an error in the for loop inside the IEnumerator SpawnWave that the class Wave does not contain the definition for count. I am not sure why that is. Here is the code below. Any help would be much appreciated.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System.Linq;
public class RoundManagerTwo : MonoBehaviour {
public enum SpawnState { SPAWNING, WAITING, COUNTING };
[System.Serializable]
public class Wave {
public string waveName;
public Transform enemy;
public int enemyRowCount;
public float spawnRate;
}
public Wave [] waves;
private int nextWave = 0;
public float timeBetweenWaves = 5f;
public float waveCountdown;
private SpawnState state = SpawnState.COUNTING;
void Start () {
waveCountdown = timeBetweenWaves;
}
void Update () {
// If it's time to start spawning rounds
if (waveCountdown <= 0) {
if (state != SpawnState.SPAWNING) {
// Start Spawning new Round
StartCoroutine (SpawnWave (waves[nextWave]));
}
} else {
waveCountdown -= Time.deltaTime;
}
}
IEnumerator SpawnWave (Wave _wave) {
state = SpawnState.SPAWNING;
for (int i = 0; i < _wave.count; i++) {
SpawnEnemy (_wave.enemy);
yield return new WaitForSeconds (1f / _wave.spawnRate);
}
state = SpawnState.WAITING;
yield break;
}
void SpawnEnemy (Transform _enemy) {
Debug.Log ("Spawning Enemy: " + _enemy.name);
}
}