How do I control where my players go, when they enter the room?

Hi, when my players enter the room I need them to be seated around a table.
I can't use the number of players in the room to pick a seat, because if say there are 3 players and the 2nd one leaves, the next player would technically be the 3rd and would sit on top of the other '3rd' player.
I want them to fill in the gaps in the seating.
Are there any callbacks that happen after all buffered RPC have happened?
Or a way to check if there are any pending rpcs?

Any advice?

Best Answers

Answers

  • I assume this updates when a player leaves? does it move everyones index back that's higher, or does it let someone take the unused number?
  • @JohnTube When does the number get assigned? I just tested it and found that of 3 players, 2 were assigned number -1 and the third was given 0. FYI I'm trying to use this during 'OnJoinedRoom'.
  • JohnTube
    JohnTube ✭✭✭✭✭
    edited February 2021
    Good question.
    Every time a possible change to the player indexes happen an event is triggered: PlayerNumbering.OnPlayerNumberingChanged but it doesn't tell you what changed or whose player's number changed.

    Both -1 and 0 are unexpected values.
    -1 means the player index is not set or assigned yet.
    0 means the game is in offline mode.

    So I would wait for the first occurrence of PlayerNumbering.OnPlayerNumberingChanged after OnJoinedRoom callback. Otherwise, I would keep trying to get the player index until I get a value >= 0.
  • @JohnTube I made a coroutine to wait for the local players player number to be > 0. It never resolved.
    I then attached onto the 'PlayerNumbering.OnPlayerNumberingChanged' to debug the player number.
    Every time it was called, it output '0'.