路点寻路
第一步:现在场景上确认几个定点,并用Gizmos
画出路线
首先在场景中确定几个空节点,放在一个父节点下面
将脚本绑在该父节点上
画出来的效果:
public class WayPoint : MonoBehaviour
{
//用一个数组对点进行存储
Transform[] points;
public Transform[] Points
{
get
{
if(points == null)
{
points = new Transform[transform.childCount];
for (int i = 0; i < points.Length; i++)
{
points[i] = transform.GetChild(i);
}
}
return points;
}
}