npc寻路

This commit is contained in:
huyulong 2024-12-14 15:19:22 +08:00
parent 52ba7a2567
commit fbc97ff6f5

View File

@ -104,6 +104,22 @@ public class RecuseNpc : MonoBehaviour
private void Update()
{
// 继续处理NPC的状态和动画
switch (nstate)
{
case Npcstate.idle:
SetAni(2);
break;
case Npcstate.run:
movebool = true;
Run(currentTarget);
break;
case Npcstate.dead:
SetAni(0);
break;
}
if (targetPoints.Count > 0)
{
currentTarget = targetPoints[0];
@ -112,7 +128,7 @@ public class RecuseNpc : MonoBehaviour
float dis = Vector3.Distance(transform.position, currentTarget);
// 停止条件改为
// 停止条件
if (movebool && dis <= 0.1f)
{
Debug.Log("到达目标点");
@ -130,6 +146,7 @@ public class RecuseNpc : MonoBehaviour
}
else
{
return;
}
}