Skip to content

Latest commit

 

History

History
31 lines (21 loc) · 1.41 KB

File metadata and controls

31 lines (21 loc) · 1.41 KB

Limiting the maximum number of players

Netcode for GameObjects provides a way to customize the connection approval process that can reject incoming connections based on any number of user-specific reasons.

The code below shows an example of an over-capacity check that would prevent more than a certain pre-defined number of players from connecting.

if( m_Portal.NetManager.ConnectedClientsIds.Count >= CharSelectData.k_MaxLobbyPlayers )
{
    return ConnectStatus.ServerFull;
}

Note

In connection approval delegate, Netcode for GameObjects doesn't support sending anything more than a Boolean back.

When using Relay, ensure the maximum number of peer connections allowed by the host satisfies the logic implemented in the connection approval delegate.