移动调整

This commit is contained in:
huyulong 2024-12-13 19:33:27 +08:00
parent b50088ffdf
commit ddc46a22ef

View File

@ -37,6 +37,9 @@ public class RecuseNpc : MonoBehaviour
// 存目的地的list
public List<Vector3> targetPoints = new List<Vector3>();
private void Awake()
{
instance = this;
@ -84,7 +87,17 @@ public class RecuseNpc : MonoBehaviour
public void SetNpcDes(Vector3 tar)
{
//target.position = tar;
NavMeshHit hit;
if (!NavMesh.SamplePosition(tar, out hit, 1.0f, NavMesh.AllAreas))
{
Debug.LogError($"目标点 {target} 不在导航网格上");
}
else
{
tar = hit.position; // 将目标点调整到最近的导航网格位置
}
targetPoints.Add(tar);
}
private void Update()