ボスの機能の作成③(ランダム・ムーブ)






チェックポイントをランダム・ムーブする
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);
}
}
}



【2021版】Danmaku(基礎/全55回)
他のコースを見る





チェックポイントをランダム・ムーブする
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);
}
}
}



ボスの機能の作成③(ランダム・ムーブ)