敵の発生装置の作成①(コルーチンの復習)

敵を拠点から生み出す(コルーチン)
using System.Collections; using System.Collections.Generic; using UnityEngine; public class EnemyGene : MonoBehaviour { public GameObject enemyPrefab; void Start() { StartCoroutine(Gene()); } private IEnumerator Gene() { // 処理Aを3回繰り返す for (int i = 0; i < 3; i++) { // 「0.2秒ごとに敵を発生させる」という処理を5回繰り返す(処理A) for (int j = 0; j < 5; j++) { // 敵を発生させる Instantiate(enemyPrefab, transform.position, Quaternion.identity); // 待機(0.2秒) yield return new WaitForSeconds(0.2f); } yield return new WaitForSeconds(1f); } } }
C#





【2021版】Danmaku(基礎/全55回)
他のコースを見る
敵を拠点から生み出す(コルーチン)
using System.Collections; using System.Collections.Generic; using UnityEngine; public class EnemyGene : MonoBehaviour { public GameObject enemyPrefab; void Start() { StartCoroutine(Gene()); } private IEnumerator Gene() { // 処理Aを3回繰り返す for (int i = 0; i < 3; i++) { // 「0.2秒ごとに敵を発生させる」という処理を5回繰り返す(処理A) for (int j = 0; j < 5; j++) { // 敵を発生させる Instantiate(enemyPrefab, transform.position, Quaternion.identity); // 待機(0.2秒) yield return new WaitForSeconds(0.2f); } yield return new WaitForSeconds(1f); } } }
C#





敵の発生装置の作成①(コルーチンの復習)