From f9356cc0d472973b41e5738d284686da9df661c6 Mon Sep 17 00:00:00 2001 From: huyulong <1838407198@qq.com> Date: Thu, 12 Dec 2024 16:02:29 +0800 Subject: [PATCH] =?UTF-8?q?npc=E7=94=9F=E6=88=90=E4=BD=8D=E7=BD=AE?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- xiaofang/Assets/ProtoBuf/test.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/xiaofang/Assets/ProtoBuf/test.cs b/xiaofang/Assets/ProtoBuf/test.cs index d8e077d3..4450e158 100644 --- a/xiaofang/Assets/ProtoBuf/test.cs +++ b/xiaofang/Assets/ProtoBuf/test.cs @@ -492,8 +492,10 @@ public class test : MonoBehaviour float x = -float.Parse(npcData.X.ToString()); float y = float.Parse(npcData.Y.ToString()); float z = float.Parse(npcData.Z.ToString()); - trans.position = new Vector3(x, y, z); - GameObject.Instantiate(npc, trans); + Vector3 position = new Vector3(x, y, z); + + // 使用指定的世界坐标位置来实例化 NPC,而不是依赖 trans 位置 + GameObject.Instantiate(npc, position, Quaternion.identity); // 直接指定位置和旋转 } if(npcData.Type == 2)//npc移动 {