Rotations Matrix

This commit is contained in:
brausjonas
2022-05-13 17:16:12 +02:00
parent a36cf65f6d
commit 04e06652f5
5 changed files with 121 additions and 7 deletions
+23 -5
View File
@@ -12,7 +12,10 @@ public class World : MonoBehaviour
private string name;
private Dictionary<byte, GameObject> otherPlayers = new Dictionary<byte, GameObject>();
private Queue<byte> playersToCreate = new Queue<byte>();
private Queue<Player.PlayerUpdateData> playersToUpdate = new Queue<Player.PlayerUpdateData>();
private Queue<Player.PlayerPositionUpdateData> playersPositionsToUpdate = new Queue<Player.PlayerPositionUpdateData>();
private Queue<Player.PlayerRotationsUpdateData> playersRotationsToUpdate =
new Queue<Player.PlayerRotationsUpdateData>();
//chunks
private Chunk[,] chunks;
@@ -36,7 +39,7 @@ public class World : MonoBehaviour
public void RemovePlayer(byte id)
{
playersToUpdate.Enqueue(new Player.PlayerUpdateData(id, Vector3.zero, true));
playersPositionsToUpdate.Enqueue(new Player.PlayerPositionUpdateData(id, Vector3.zero, true));
}
private void Update()
@@ -58,9 +61,9 @@ public class World : MonoBehaviour
otherPlayers.Add(id, player);
}
if (playersToUpdate.Count > 0)
if (playersPositionsToUpdate.Count > 0)
{
Player.PlayerUpdateData data = playersToUpdate.Dequeue();
Player.PlayerPositionUpdateData data = playersPositionsToUpdate.Dequeue();
otherPlayers.TryGetValue(data.id, out GameObject g);
if (g != null)
{
@@ -72,11 +75,26 @@ public class World : MonoBehaviour
}
}
}
if (playersRotationsToUpdate.Count > 0)
{
Player.PlayerRotationsUpdateData data = playersRotationsToUpdate.Dequeue();
otherPlayers.TryGetValue(data.id, out GameObject g);
if (g != null)
{
g.transform.rotation = data.rotation;
}
}
}
public void UpdatePlayerPosition(Vector3 position, byte id)
{
playersToUpdate.Enqueue(new Player.PlayerUpdateData(id, position, false));
playersPositionsToUpdate.Enqueue(new Player.PlayerPositionUpdateData(id, position, false));
}
public void UpdatePlayerRotation(Quaternion rotation, byte id)
{
playersRotationsToUpdate.Enqueue(new Player.PlayerRotationsUpdateData(id, rotation));
}
public void AddPlayer(byte id)