Make respawning happen
This commit is contained in:
parent
e127e253d1
commit
1562209504
@ -84,7 +84,6 @@ namespace NeonTea.Quakeball.Networking.Instances {
|
|||||||
SelfIdentified = true;
|
SelfIdentified = true;
|
||||||
|
|
||||||
SpawnPckt spawn = new SpawnPckt(LocalPlayer.Controlled.transform.position);
|
SpawnPckt spawn = new SpawnPckt(LocalPlayer.Controlled.transform.position);
|
||||||
spawn.Location = LocalPlayer.Controlled.transform.position;
|
|
||||||
Peer.SendReliable(Server.uid, spawn);
|
Peer.SendReliable(Server.uid, spawn);
|
||||||
} else if (packet is SpawnPckt) {
|
} else if (packet is SpawnPckt) {
|
||||||
SpawnPckt spawn = (SpawnPckt)packet;
|
SpawnPckt spawn = (SpawnPckt)packet;
|
||||||
|
@ -78,6 +78,7 @@ namespace NeonTea.Quakeball.Networking.Instances {
|
|||||||
public override void Handle(Connection conn, Packet packet) {
|
public override void Handle(Connection conn, Packet packet) {
|
||||||
if (packet is SpawnPckt) {
|
if (packet is SpawnPckt) {
|
||||||
SpawnPckt spawn = (SpawnPckt)packet;
|
SpawnPckt spawn = (SpawnPckt)packet;
|
||||||
|
Debug.Log(spawn.IsInitial);
|
||||||
if (Players[conn.uid].Controlled == null && spawn.IsInitial) {
|
if (Players[conn.uid].Controlled == null && spawn.IsInitial) {
|
||||||
Player obj = Net.SpawnPlayer(spawn.Location).GetComponent<Player>();
|
Player obj = Net.SpawnPlayer(spawn.Location).GetComponent<Player>();
|
||||||
Players[conn.uid].Controlled = obj;
|
Players[conn.uid].Controlled = obj;
|
||||||
|
@ -8,6 +8,8 @@ namespace NeonTea.Quakeball.Networking.Packets {
|
|||||||
public Vector3 Location;
|
public Vector3 Location;
|
||||||
public bool IsInitial;
|
public bool IsInitial;
|
||||||
|
|
||||||
|
public SpawnPckt() { }
|
||||||
|
|
||||||
public SpawnPckt(Vector3 location, ulong id = 0, bool isinitial = true) {
|
public SpawnPckt(Vector3 location, ulong id = 0, bool isinitial = true) {
|
||||||
PlayerId = id;
|
PlayerId = id;
|
||||||
Location = location;
|
Location = location;
|
||||||
@ -15,18 +17,13 @@ namespace NeonTea.Quakeball.Networking.Packets {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public override void Read(ByteBuffer buffer) {
|
public override void Read(ByteBuffer buffer) {
|
||||||
float x = buffer.ReadFloat();
|
Location = buffer.ReadVector3();
|
||||||
float y = buffer.ReadFloat();
|
|
||||||
float z = buffer.ReadFloat();
|
|
||||||
Location = new Vector3(x, y, z);
|
|
||||||
PlayerId = buffer.ReadULong();
|
PlayerId = buffer.ReadULong();
|
||||||
IsInitial = buffer.ReadBool();
|
IsInitial = buffer.ReadBool();
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Write(ByteBuffer buffer) {
|
public override void Write(ByteBuffer buffer) {
|
||||||
buffer.Write(Location.x);
|
buffer.Write(Location);
|
||||||
buffer.Write(Location.y);
|
|
||||||
buffer.Write(Location.z);
|
|
||||||
buffer.Write(PlayerId);
|
buffer.Write(PlayerId);
|
||||||
buffer.Write(IsInitial);
|
buffer.Write(IsInitial);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user