Make respawning happen

This commit is contained in:
Sofia 2020-08-08 09:57:59 +03:00
parent e127e253d1
commit 1562209504
3 changed files with 5 additions and 8 deletions

View File

@ -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;

View File

@ -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<Player>();
Players[conn.uid].Controlled = obj;

View File

@ -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);
}