Hello everyone,
I’m trying to use Lobby in a certain way but I’m having lot of problems so maybe I’m doing it wrong, so I want to hear your opinions:
- I want the host to create a lobby and invite other players, my game needs 4 players to start to be played 2 v 2, and there is possibility to join lobby to spectate
- so in lobby I have player data as follow :
{
isSpectator : Boolean,
position: Integer
}
position
is used to define the teams, (0, 1) vs (2, 3)- the host is always in position 0
- when a player joins the lobby, he joins with
isSpectator = true
, so it doesn’t have a position, when he joins successfully, he parses the players in lobby and checkposition
, then if a position from {1, 2, 3} is available, he updates his data and set his position to the available one, otherwise he stays as spectator
the problem I’m facing is, it happens that all players join at same time so they got same free position, and they all take it, which causes problem …
So I’m not sure if I’m on good path or there is a better way, can you please share your thoughts
thank you in advance