中継地点を巡回させる;その1

中継地点を巡回させる
using UnityEngine;
using System.Collections;
public class Patrol : MonoBehaviour {
public Transform[] points;
private int destPoint = 0;
private NavMeshAgent agent;
void Start () {
agent = GetComponent<NavMeshAgent>();
agent.autoBraking = false;
GoToNextPoint();
}
void GoToNextPoint(){
if(points.Length == 0)
return;
agent.destination = points[destPoint].position;
destPoint = (destPoint + 1) % points.Length;
}
void Update () {
if(agent.remainingDistance < 0.5f)
GoToNextPoint();
}
}

Unity Code Memo
他のコースを見る
中継地点を巡回させる
using UnityEngine;
using System.Collections;
public class Patrol : MonoBehaviour {
public Transform[] points;
private int destPoint = 0;
private NavMeshAgent agent;
void Start () {
agent = GetComponent<NavMeshAgent>();
agent.autoBraking = false;
GoToNextPoint();
}
void GoToNextPoint(){
if(points.Length == 0)
return;
agent.destination = points[destPoint].position;
destPoint = (destPoint + 1) % points.Length;
}
void Update () {
if(agent.remainingDistance < 0.5f)
GoToNextPoint();
}
}

中継地点を巡回させる;その1