敵ロボットの製造装置を作る
![30cdd7b2 9f69 4445 b52d bc4b8aa76473](https://codegenius.org/uploads/slide/image/7857/30cdd7b2-9f69-4445-b52d-bc4b8aa76473.jpeg)
![9e28b819 cde5 41a6 a29a c8ab44037a54](https://codegenius.org/uploads/slide/image/7858/9e28b819-cde5-41a6-a29a-c8ab44037a54.jpeg)
![5250d919 4088 46ce ba73 9539913f6f36](https://codegenius.org/uploads/slide/image/7859/5250d919-4088-46ce-ba73-9539913f6f36.jpeg)
敵を生み出す(コルーチン)
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class EnemyGene : MonoBehaviour
{
public GameObject enemyPrefab;
void Start()
{
StartCoroutine(BotGene());
}
// コルーチンの活用
private IEnumerator BotGene()
{
yield return new WaitForSeconds(2f);
for (int i = 0; i < 5; i++)
{
Instantiate(enemyPrefab, transform.position, transform.rotation);
yield return new WaitForSeconds(1);
}
}
}
![B8443d52 864e 420d 89a1 53741059f49c](https://codegenius.org/uploads/slide/image/7860/b8443d52-864e-420d-89a1-53741059f49c.jpeg)
![C8a936cd c8b5 4aa2 9799 f8a7d8a64bbb](https://codegenius.org/uploads/slide/image/7861/c8a936cd-c8b5-4aa2-9799-f8a7d8a64bbb.jpeg)
![04391163 558a 45ac 92cf b05593bf6472](https://codegenius.org/uploads/slide/image/7862/04391163-558a-45ac-92cf-b05593bf6472.jpeg)
![30cdd7b2 9f69 4445 b52d bc4b8aa76473](https://codegenius.org/uploads/slide/image/7857/30cdd7b2-9f69-4445-b52d-bc4b8aa76473.jpeg)
![9e28b819 cde5 41a6 a29a c8ab44037a54](https://codegenius.org/uploads/slide/image/7858/9e28b819-cde5-41a6-a29a-c8ab44037a54.jpeg)
![5250d919 4088 46ce ba73 9539913f6f36](https://codegenius.org/uploads/slide/image/7859/5250d919-4088-46ce-ba73-9539913f6f36.jpeg)
敵を生み出す(コルーチン)
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class EnemyGene : MonoBehaviour
{
public GameObject enemyPrefab;
void Start()
{
StartCoroutine(BotGene());
}
// コルーチンの活用
private IEnumerator BotGene()
{
yield return new WaitForSeconds(2f);
for (int i = 0; i < 5; i++)
{
Instantiate(enemyPrefab, transform.position, transform.rotation);
yield return new WaitForSeconds(1);
}
}
}
![B8443d52 864e 420d 89a1 53741059f49c](https://codegenius.org/uploads/slide/image/7860/b8443d52-864e-420d-89a1-53741059f49c.jpeg)
![C8a936cd c8b5 4aa2 9799 f8a7d8a64bbb](https://codegenius.org/uploads/slide/image/7861/c8a936cd-c8b5-4aa2-9799-f8a7d8a64bbb.jpeg)
![04391163 558a 45ac 92cf b05593bf6472](https://codegenius.org/uploads/slide/image/7862/04391163-558a-45ac-92cf-b05593bf6472.jpeg)
敵ロボットの製造装置を作る