Is it possible for room.PlayerCount to be the same for two joined players

Options
Hello, i am making a 4 player board game, in which depending on your id (a value between 0 and 3) you are the blue player or the green player etc.
The id of the player is set in the method OnJoinedRoom.
Here is a segment of the code:

public override void OnJoinedRoom() { int playerId = PhotonNetwork.room.PlayerCount - 1; SetCustomProperties(playerId); } private void SetCustomProperties(int playerId) { EXTHashtable customProperties = null; customProperties = new EXTHashtable() { { "id", playerId }, { "username", username }}; PhotonNetwork.player.SetCustomProperties(customProperties); }

Ok what happened while testing is that two players were controlling the same color, which could only happen if they had the same playerId value.
Also ,I don't know if it helps, some players could see tha name of the double controller player as either the username of the one player (which is the value from the "username" property) or the other player. The two aforementioned players saw the other person's name in their device.

1. One assumption I have is that for some reason both players when they joined, had the same PhotonNetwork.room.PlayerCount value. No one had exited the room in the meantime, the playerId is fixed accordinlgy when a player exits.
2. The second assumption is that while testing these clients were already in a room before (everything was working there), which they left and then joined another room. Is it possible that the new PhotonNetwork.player.SetCustomProperties(customProperties) did not change the previous "id" property with the new one for some player?

Furthermore, one of the two players had some slow internet issues, i don't know if that would affect anythting.

Also:
This does not happen often, in fact I cannot reproduce it after an hour of testing, trying to click the join room button simultaneously on two clients in order to reproduce this problem. Furthermore, after almost 2 months of development it is the first time i have encountered this problem.

Any help would be appreicated

Comments

  • JohnTube
    JohnTube ✭✭✭✭✭
    edited January 2017
    Options
    Hi @AlexP,

    This is expected as player count is synced across joined actors.
    Why don't you use the ActorNr as your player ID? There is no need to reinvent the wheel!
    PhotonNetwork.player.ID