There are few things i didn’t understand well. Would be great if you guys explain. Would be even better if you can explain with examples and analogies. This is how i learn best
- What’s going on in the line I’ve added a comment to?
private IEnumerator SpawnAllEnemiesInWave(WaveConfig waveConfig) { for (int enemyCount = 0; enemyCount < waveConfig.GetNumberOfEnemies(); enemyCount++) { var newEnemy = Instantiate(waveConfig.GetEnemyPrefab(), waveConfig.GetWaypoints()[0].transform.position, Quaternion.identity); newEnemy.GetComponent<EnemyPathing>().SetWaveConfig(waveConfig); //What's going on here? yield return new WaitForSeconds(waveConfig.GetTimeBetweenSpawns()); } }
- I really didn’t get the foreach loop part. Can you explain it step by step?
public List<Transform> GetWaypoints() { var waveWaypoints = new List<Transform>(); foreach (Transform child in pathPrefab.transform) { waveWaypoints.Add(child); } return waveWaypoints; }