Spawn players to different position

Options
I have 4 positions a player can spawn in. The way I had it set up was by using numberOFPlayers= PhotonNetwork.CountOfPlayers;
and then
if (numberOFPlayers == 1)
{

PhotonNetwork.Instantiate(Path.Combine("PhotonPrefabs", "MyPlayer"), spawnPoints[0].position, Quaternion.identity, 0);
numberOFPlayers = 2;
}

and so on for each player. That was working when I had players join separately but now I have my game set up where there is a waiting room and once 4 players join they all go in the game at the same time. So keeping it the way I have set up is not working any more as some are now instantiating at the same position if they joining at the same exact time as the numberofplayers is not updating per user it is 4 right away since there are 4 players.


Is there a way to separate it like player1, player2.. and so on. and instantiate based on the order they joined the room.


Or any other way to instantiate at different positions.


Thanks for any help.

Comments

  • Scoopa
    Options
    Hey JJ10,
    I know the post is 2 years old by now, but I currently have exactly the same issue and am curious if you found a fix and could tell me about it.
    Thank you for your help! (if you even read this message :D)
  • the general idea the very similar to PhotonTeamsManager - only one player/system to determine whom in which spawnpoint/ team.

    you can let Master Client determine which spawn point should be used when OnJoinedRoom or using RoomProperties + Check And Swap, trying set specific room property to self as a proof owning the spawn point