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移动 {