我试图让一个立方体跟随我的玩家,但是每当我运行代码时,我都会收到错误:"SetDestination" can only be called on an active agent that has been placed on a NavMesh. UnityEngine.AI.NavMeshAgent.SetDestination(Vector3)
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.AI;
public class CubeFollowPlayer : MonoBehaviour {
public GameObject target = null;
private NavMeshAgent nma = null;
private void Start()
{
nma = this.GetComponent<NavMeshAgent>();
}
public void Update () {
nma.SetDestination(target.transform.position);
}
}
我将如何解决该错误?