移动调整
This commit is contained in:
parent
b50088ffdf
commit
ddc46a22ef
@ -37,6 +37,9 @@ public class RecuseNpc : MonoBehaviour
|
|||||||
// 存目的地的list
|
// 存目的地的list
|
||||||
public List<Vector3> targetPoints = new List<Vector3>();
|
public List<Vector3> targetPoints = new List<Vector3>();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private void Awake()
|
private void Awake()
|
||||||
{
|
{
|
||||||
instance = this;
|
instance = this;
|
||||||
@ -84,7 +87,17 @@ public class RecuseNpc : MonoBehaviour
|
|||||||
public void SetNpcDes(Vector3 tar)
|
public void SetNpcDes(Vector3 tar)
|
||||||
{
|
{
|
||||||
//target.position = 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);
|
targetPoints.Add(tar);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Update()
|
private void Update()
|
||||||
|
Loading…
Reference in New Issue
Block a user