[PUN2] Player in PhotonNetwork.PlayerList has no UserId

Hello,

I have a room with two players in it.

When checking PhotonNetwork.PlayerList, only the local player has a UserId. The other has “null”. It doesn’t matter if the user is the MasterClient or not.

I tried to add this code before connecting, but to no aval:

if (PhotonNetwork.AuthValues == null)
{
    PhotonNetwork.AuthValues = new AuthenticationValues(System.Guid.NewGuid().ToString());
}
else
{
    PhotonNetwork.AuthValues.UserId = System.Guid.NewGuid().ToString();
}

Any idea why this is happening?

I was running into this issue, and found a ‘gotcha’ in the documentation of UserID:

UserId of the player, available when the room got created with RoomOptions.PublishUserId = true.

Like this:

RoomOptions roomOpts = new RoomOptions()
{
    IsVisible = true,
    IsOpen = true,
    MaxPlayers = 10,
    PublishUserId = true
};