路径测试1

This commit is contained in:
杨号敬 2024-12-16 12:01:51 +08:00
parent 144727feb3
commit a3e794dd82

View File

@ -88,20 +88,21 @@ public class RecuseNpc : MonoBehaviour
{ {
Debug.Log(tar+"目标路径点"); Debug.Log(tar+"目标路径点");
//target.position = tar; target.position = tar;
//Debug.Log(target); Debug.Log(target);
//NavMeshHit hit; NavMeshHit hit;
//if (!NavMesh.SamplePosition(tar, out hit, 1.0f, NavMesh.AllAreas)) if (!NavMesh.SamplePosition(tar, out hit, 1.0f, NavMesh.AllAreas))
//{ {
// Debug.LogError($"目标点 {target} 不在导航网格上"); Debug.LogError($"目标点 {target} 不在导航网格上");
//} }
//else else
//{ {
// tar = hit.position; // 将目标点调整到最近的导航网格位置 tar = hit.position; // 将目标点调整到最近的导航网格位置
//} }
//Debug.Log("进入奔跑++++++="); Debug.Log("进入奔跑++++++=");
//targetPoints.Add(tar); targetPoints.Clear();
navMeshAgent.SetDestination(tar); targetPoints.Add(tar);
} }