Why can I not get userIDs?
Options
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!
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!
0
Comments
-
Hi @Dragonslash,
Thank you for choosing Photon!
When you create rooms, set RoomOptions.PublishUserId to true.0 -
Hi @Dragonslash,
Thank you for choosing Photon!
When you create rooms, set RoomOptions.PublishUserId to true.
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?
0 -
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.0 -
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
2