[Solved] Can't join room with the same "player.NickName"

Options
Hello guys! I'm facing some strange issue here.
After i updated my project to Unity 2018 and PUN 1.9, i'm facing some strange behaviour.
There is a logick in my project which sets the default player nickname to "Player".
I have 2 devices, default name is setted on both of them. Then i try to create room with one device and connect on other device, i see error:
Operation failed: OperationResponse 226: ReturnCode: 32746 (Join failed: UserId 'Player' already joined the specified game (JoinMode=0).). Parameters: {} Server: GameServer
BUT i dont set UserId anywhere. I'm only calling PhotonNetwork.player.NickName = "Player".
It seems that PUN does not generate random UserId for the session for some reason.
If i change PhotonNetwork.player.NickName = "Player1" on one of the devices, everything works ok.

And the second strange thing - before update (Unity 5.6.1 + PUN 1.85) the same code worked just fine and i have had no problems with connecting 2 players with the same nickname.

Could you please help me to solve this issue?
Thank you!

Comments

  • JohnTube
    JohnTube ✭✭✭✭✭
    Options
    Hi @LeonidB,

    PhotonNetwork.player.NickName
    Should not set the UserId. You are probably setting the UserId before connecting. Can you log the values for the UserId per player? Maybe look for all references to the PhotonPlayer.UserId in your code. Or maybe you are using Custom Authentication and returning same UserId value.

    And the second strange thing - before update (Unity 5.6.1 + PUN 1.85) the same code worked just fine and i have had no problems with connecting 2 players with the same nickname.

    Since PUN 1.88, by default, each player inside a room must have a unique UserId.
    Changed: The room option "CheckUserOnJoin" is now always used. This means you have to use UserIDs to be able to rejoin a room. This was enabled before in most cases but now it's mandatory. If you don't set a userID, the server will assign a temp one for the "session".
  • LeonidB
    Options
    Hello @JohnTube!
    Thank you very much! It seems, if UserId is not setted manually or through custom authentication system, its automatically set as = player.PlayerName.
    I'm now assigning UserId = random 6 digits string, on OnJoinedLobby and it works perfectly.