using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.AI;//引入AI,才能操作导航系统的组件 public class PlayerGo : MonoBehaviour { private NavMeshAgent m_NavMeshAgent;//定义Cube身上的NavMeshAgent public Transform m_Transform; //公开定义我们的Sphere // Use this for initialization void Start () { m_NavMeshAgent = gameObject.GetComponent(); }
// Update is called once per frame
void Update () {
//方法:SetDestination(目标点位置);
//m\_NavMeshAgent.SetDestination(m\_Transform.position);
//属性:destination = 目标点位置;
m\_NavMeshAgent.destination = m\_Transform.position;
//18行代码和21行代码作用一样,都是引导目的地的位置
}