ボスの機能の作成③(ランダム・ムーブ)
![A4d88481 a3f3 491c 9579 36053f5d5535](https://codegenius.org/uploads/slide/image/7763/a4d88481-a3f3-491c-9579-36053f5d5535.jpeg)
![Cf4167f2 31d1 43df a24c c06a75d51e7a](https://codegenius.org/uploads/slide/image/7764/cf4167f2-31d1-43df-a24c-c06a75d51e7a.jpeg)
![C21b3ba1 c621 455b b798 73e6a200fc6b](https://codegenius.org/uploads/slide/image/7765/c21b3ba1-c621-455b-b798-73e6a200fc6b.jpeg)
![0c86bb7f 9387 422e 8d10 bbfc905ca976](https://codegenius.org/uploads/slide/image/7766/0c86bb7f-9387-422e-8d10-bbfc905ca976.jpeg)
![8d142471 3db3 4920 ad62 0e812a1e268d](https://codegenius.org/uploads/slide/image/7767/8d142471-3db3-4920-ad62-0e812a1e268d.jpeg)
![D670b661 d0c1 4d6a a506 7b513ce419d2](https://codegenius.org/uploads/slide/image/7768/d670b661-d0c1-4d6a-a506-7b513ce419d2.jpeg)
チェックポイントをランダム・ムーブする
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class BossMove : MonoBehaviour
{
public Transform[] points;
private int num = 0;
void Start()
{
StartCoroutine(MoveB());
}
void Update()
{
transform.position = Vector3.MoveTowards(transform.position, points[num].position, 0.2f);
}
private IEnumerator MoveB()
{
while (true)
{
yield return new WaitForSeconds(3f);
num = Random.Range(0, points.Length);
}
}
}
![F641de9a 62a4 4e65 85fa 3f34b800a33f](https://codegenius.org/uploads/slide/image/7769/f641de9a-62a4-4e65-85fa-3f34b800a33f.jpeg)
![82aa5d05 9b43 4d10 b942 865456a9b3e1](https://codegenius.org/uploads/slide/image/7770/82aa5d05-9b43-4d10-b942-865456a9b3e1.jpeg)
![D553c893 94eb 44ad b5d7 39f8bf64fe6d](https://codegenius.org/uploads/slide/image/7771/d553c893-94eb-44ad-b5d7-39f8bf64fe6d.jpeg)
【2021版】Danmaku(基礎/全55回)
他のコースを見る![A4d88481 a3f3 491c 9579 36053f5d5535](https://codegenius.org/uploads/slide/image/7763/a4d88481-a3f3-491c-9579-36053f5d5535.jpeg)
![Cf4167f2 31d1 43df a24c c06a75d51e7a](https://codegenius.org/uploads/slide/image/7764/cf4167f2-31d1-43df-a24c-c06a75d51e7a.jpeg)
![C21b3ba1 c621 455b b798 73e6a200fc6b](https://codegenius.org/uploads/slide/image/7765/c21b3ba1-c621-455b-b798-73e6a200fc6b.jpeg)
![0c86bb7f 9387 422e 8d10 bbfc905ca976](https://codegenius.org/uploads/slide/image/7766/0c86bb7f-9387-422e-8d10-bbfc905ca976.jpeg)
![8d142471 3db3 4920 ad62 0e812a1e268d](https://codegenius.org/uploads/slide/image/7767/8d142471-3db3-4920-ad62-0e812a1e268d.jpeg)
![D670b661 d0c1 4d6a a506 7b513ce419d2](https://codegenius.org/uploads/slide/image/7768/d670b661-d0c1-4d6a-a506-7b513ce419d2.jpeg)
チェックポイントをランダム・ムーブする
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class BossMove : MonoBehaviour
{
public Transform[] points;
private int num = 0;
void Start()
{
StartCoroutine(MoveB());
}
void Update()
{
transform.position = Vector3.MoveTowards(transform.position, points[num].position, 0.2f);
}
private IEnumerator MoveB()
{
while (true)
{
yield return new WaitForSeconds(3f);
num = Random.Range(0, points.Length);
}
}
}
![F641de9a 62a4 4e65 85fa 3f34b800a33f](https://codegenius.org/uploads/slide/image/7769/f641de9a-62a4-4e65-85fa-3f34b800a33f.jpeg)
![82aa5d05 9b43 4d10 b942 865456a9b3e1](https://codegenius.org/uploads/slide/image/7770/82aa5d05-9b43-4d10-b942-865456a9b3e1.jpeg)
![D553c893 94eb 44ad b5d7 39f8bf64fe6d](https://codegenius.org/uploads/slide/image/7771/d553c893-94eb-44ad-b5d7-39f8bf64fe6d.jpeg)
ボスの機能の作成③(ランダム・ムーブ)