Quantcast
Channel: Questions in topic: "count"
Viewing all articles
Browse latest Browse all 187

Array that I am using in a IEnumerator parameter does not contain a definition for count?

$
0
0
Hello I am following this tutorial for Wave Spawning in my game: [link text][1] [1]: https://www.youtube.com/watch?v=Vrld13ypX_I&t=44s 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); } }

Viewing all articles
Browse latest Browse all 187

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>