diff --git a/Assets/Scripts/Networking/Instances/Client.cs b/Assets/Scripts/Networking/Instances/Client.cs index 0759822..45ece22 100644 --- a/Assets/Scripts/Networking/Instances/Client.cs +++ b/Assets/Scripts/Networking/Instances/Client.cs @@ -84,7 +84,6 @@ namespace NeonTea.Quakeball.Networking.Instances { SelfIdentified = true; SpawnPckt spawn = new SpawnPckt(LocalPlayer.Controlled.transform.position); - spawn.Location = LocalPlayer.Controlled.transform.position; Peer.SendReliable(Server.uid, spawn); } else if (packet is SpawnPckt) { SpawnPckt spawn = (SpawnPckt)packet; diff --git a/Assets/Scripts/Networking/Instances/Server.cs b/Assets/Scripts/Networking/Instances/Server.cs index e761fb9..8c183a3 100644 --- a/Assets/Scripts/Networking/Instances/Server.cs +++ b/Assets/Scripts/Networking/Instances/Server.cs @@ -78,6 +78,7 @@ namespace NeonTea.Quakeball.Networking.Instances { public override void Handle(Connection conn, Packet packet) { if (packet is SpawnPckt) { SpawnPckt spawn = (SpawnPckt)packet; + Debug.Log(spawn.IsInitial); if (Players[conn.uid].Controlled == null && spawn.IsInitial) { Player obj = Net.SpawnPlayer(spawn.Location).GetComponent(); Players[conn.uid].Controlled = obj; diff --git a/Assets/Scripts/Networking/Packets/SpawnPckt.cs b/Assets/Scripts/Networking/Packets/SpawnPckt.cs index 54606a0..18a6db6 100644 --- a/Assets/Scripts/Networking/Packets/SpawnPckt.cs +++ b/Assets/Scripts/Networking/Packets/SpawnPckt.cs @@ -8,6 +8,8 @@ namespace NeonTea.Quakeball.Networking.Packets { public Vector3 Location; public bool IsInitial; + public SpawnPckt() { } + public SpawnPckt(Vector3 location, ulong id = 0, bool isinitial = true) { PlayerId = id; Location = location; @@ -15,18 +17,13 @@ namespace NeonTea.Quakeball.Networking.Packets { } public override void Read(ByteBuffer buffer) { - float x = buffer.ReadFloat(); - float y = buffer.ReadFloat(); - float z = buffer.ReadFloat(); - Location = new Vector3(x, y, z); + Location = buffer.ReadVector3(); PlayerId = buffer.ReadULong(); IsInitial = buffer.ReadBool(); } public override void Write(ByteBuffer buffer) { - buffer.Write(Location.x); - buffer.Write(Location.y); - buffer.Write(Location.z); + buffer.Write(Location); buffer.Write(PlayerId); buffer.Write(IsInitial); }