Why can I not get userIDs?

I am trying to create a multiplayer RPG using PUN. I am hoping for the master to have each player's tagobject associated with their respective player gameobject. I am thinking I need this so the master client can dish out XP, loot, etc - so the master will need to access player's stat scripts etc from their player userID which I hope to pass around. Feel free to let me know if that's a stupid way of going about things...

Now I have set share UserID to true when creating the room, however when the master is printing all of the players in the playerlist it does not print other player's userID...

https://imgur.com/a/iasg3xD

Thank you!

Comments

  • JohnTube wrote: »

    Hello JohnTube,

    Thanks for your reply. As far as I am aware I already am setting this option, please check out the imgur link in my original post - perhaps there is something I am doing incorrectly there?
  • coracii
    coracii
    edited September 2020
    I'm having the same issue after upgrading to Pun 2.22, Photon lib 4.1.4.5, on Unity 2019.4.5
    PhotonNetwork.JoinOrCreateRoom(roomName, 
        new RoomOptions() { MaxPlayers = MAX_PLAYERS, PublishUserId = true }, 
        TypedLobby.Default);
    
    public override void OnPlayerEnteredRoom(Player player)
    {
        Debug.Log(player.UserId);   // Outputs null when a second player joins using the updated PUN/Unity version
    }
    

    The code worked as expected on Pun 2.6, Photon lib 4.1.2.7, on Unity 2018.4. The package was installed by downloading Photon Voice 2 from the asset store.
  • JohnTube
    JohnTube mod
    edited September 2020
    Hi @coracii,

    Thank you for choosing Photon!

    @Dragonslash, @coracii

    Thank you for your report, for you patience and understanding!

    I have reproduced this and here is what you could do as workarounds (A or B or C) until we fix this in the next update:

    A. set a Nickname for the local player before connecting (must be non null and non empty).
    B. set a custom actor property before connecting (anything with string key)
    C. modify code:

    In LoadBalancingPeer.cs, inside OpJoinRoom replace:
    if (opParams.OnGameServer)
                {
                    if (opParams.PlayerProperties != null && opParams.PlayerProperties.Count > 0)
                    {
                        op[ParameterCode.PlayerProperties] = opParams.PlayerProperties;
                        op[ParameterCode.Broadcast] = true; // broadcast actor properties
                    }
    
    with:
    if (opParams.OnGameServer)
                {
                    if (opParams.PlayerProperties != null && opParams.PlayerProperties.Count > 0)
                    {
                        op[ParameterCode.PlayerProperties] = opParams.PlayerProperties;
                    }
                    op[ParameterCode.Broadcast] = true; // broadcast actor properties
    
  • @JohnTube thanks for providing workarounds for this issue, I went with option B and worked fine.

    My game has some logic that depends on the userID to be published in the room. Any ideas as to when this issue will be resolved?
  • Hi @RoyNexus,

    Thank you for choosing Photon!

    In the next PUN 2 update which is scheduled -if everything goes according to plan- for this week.
  • Hi @JohnTube , I was just wondering if this was fixed ? I'm still having the same problem. Thanks
  • Hi @dibset,

    yes this fixed since November 2020.
  • @JohnTube, i am having the same problem, only masterclient is able to view userid of others but others can't view userid of any of the other player. Yes publishuserid is true when creating a room. Would you like me to put my code here or create a new discussion?

  • Make sure you are using latest PUN2 first.
    See here.

    Make sure all clients are joined to the same room.

    Then make sure the room has PublishUserId set to true (PhotonNetwork.CurrentRoom.PublishUserId).