npc寻路

This commit is contained in:
liuliang 2024-12-29 16:48:19 +08:00
parent 31eb5af6d7
commit f07db0d476
2 changed files with 13 additions and 1 deletions

View File

@ -517,6 +517,7 @@ public class ZZUIManager : MonoBehaviour
SplitData(TempNPC);
for(int i=0;i<NPCdian.Count;i++)
{
NPCController.instance.INITNPCMOVE(NPCdian[i]);
Debug.LogError(NPCdian[i]);
}
DiaLogBox.SetActive(false);

View File

@ -21,11 +21,22 @@ public class NPCController : MonoBehaviour
{
instance = this;
}
public void INITNPCMOVE(Vector3 pos)
{
foreach (var npcDict in npcsList)
{
foreach (var kvp in npcDict)
{
RecuseNpc npc = kvp.Key;
npc.SetNpcDes(pos);
}
}
}
public void InitNPC(Vector3 v,NpcData npcData)
{
// 使用指定的世界坐标位置来实例化 NPC而不是依赖 trans 位置
GameObject go = GameObject.Instantiate(npc, v, Quaternion.identity); // 直接指定位置和旋转
GameObject go = GameObject.Instantiate(npc, v, Quaternion.identity); // 直接指定位置和旋转c
RecuseNpc recuseNpc = go.GetComponent<RecuseNpc>();
recuseNpc.SetNPCInfo(npcData.UserId);//初始化npcid
Debug.Log(npcData.UserId);