From 470a48bbe0b23172bc1444994e48c0e4cf4fc2c2 Mon Sep 17 00:00:00 2001 From: Tore Bergebakken Date: Tue, 4 Jun 2024 08:52:18 +0200 Subject: [PATCH] Registrer connected players correctly The issue with multiple local players on one client was likely due to the connectedPlayers list not being populated with those extra players, making the server think it needed to spawn a disconnected player for them. Whoops. --- Assets/Scripts/Control&Input/Peer2PeerTransport.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Assets/Scripts/Control&Input/Peer2PeerTransport.cs b/Assets/Scripts/Control&Input/Peer2PeerTransport.cs index 479e3c716..273c489fb 100644 --- a/Assets/Scripts/Control&Input/Peer2PeerTransport.cs +++ b/Assets/Scripts/Control&Input/Peer2PeerTransport.cs @@ -360,11 +360,13 @@ private void OnSpawnPlayerInput(NetworkConnectionToClient connection, PlayerConn { isConnectionAlreadyPresent = false; connections.Add(connection); - connectedPlayers.Add((uint)playerIndex); } + + // Register player if (!playersForConnection.ContainsKey(connection.connectionId)) playersForConnection[connection.connectionId] = new(); playersForConnection[connection.connectionId].Add((uint)playerIndex); + connectedPlayers.Add((uint)playerIndex); // Determine metadata var playerType = PlayerType.Local;