添加新物体,命名为Player,添加组件Nav Mesh Agent.同时添加Navigation,将
需要进行自动寻路的地方进行烘焙。创建脚本Follow:
using UnityEngine; using System.Collections;
public class Follow : MonoBehaviour
{
public Transform target;
private NavMeshAgent agent; void Start() { agent = GetComponent<NavMeshAgent>(); }
// Update is called once per frame
void Update() { if (target != null) { agent.destination = target.position |
[Unity3D]Unity3D自动寻路Demo
最新推荐文章于 2025-04-16 10:18:34 发布