Skip to content

Commit

Permalink
Registrer connected players correctly
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
toberge committed Jun 4, 2024
1 parent fc913a1 commit 87ace5b
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion Assets/Scripts/Control&Input/Peer2PeerTransport.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 87ace5b

Please sign in to comment.