Minimum Players

Any way of forcing a Network lobby to wait for a minimum amount of players before it’ll start?

Thanks,

Lukas

1 Like

I want know this too.

this is in for 5.2. along with a callback to allow custom handling when all players are ready.

Thanks for the reply. Any sort of estimation how long it’ll be til we receive 5.2? It would be useful as well if we could have a mechanism on the server to force a game to start regardless of whether players are ready if too much time has passed.

You could very easily write a function so that every time someone connects it adds to a variable (and minus 1 every time someone disconnects) and compare it to your desired minimum players.

int minimumPlayers = 4;
int currentPlayers = 0;

//Called in OnServerConnect or OnServerDisconnect
public void PlayerCheck (int x){
   //x = 1 on connect and -1 on disconnect 
   currentPlayer += 0;
   if(currentPlayers == minimumPlayers){
      StartGame();
   }
}

This could probably be put in a bool function but that’s how I do it.

I don’t think that works as if a client calls SendReadyToBeginMessage(), the server seems to automatically check that all players are ready and then start the game. As far as I’m aware you can’t override that behaviour.

Since yesterday the “Networking Lobby Example” is available:

In the LobbyManager script is the variable MinPlayer ( in SpawnInfo)!
The PlayScene is a simple Ping-Pong game → 2 Players.

May be it helps!