1.首先创建多个空的游戏物体,用来一次规划出敌人要行走的路线,并且设置标记,方便查看
2.编写获取每个路径点的脚本WayPoint:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class WayPoint : MonoBehaviour
{
//创建一个数组 用来保存 路径点
public static Transform[] wayPoint;
private void Awake()
{
//给 保存路径点的数组 长度
wayPoint = new Transform[transform.childCount];
//将路径点 依次存入数组
for (int i = 0; i < wayPoint.Length; i++)
{
wayPoint[i] = transform.GetChild(i);
Debug.Log("wayPoint:"+wayPoint[i]);
}
}
}
将获取路径点的脚本WayPoint挂载在点的父级物体上: