Problem with player custom properties

Options
Hi,

PUN is excellent and everything so far has been pretty straight forward, but I am hitting an issue accessing other player custom properties and was wondering if anyone could give me a nudge in the right direction. Here is how I am setting the first player's username who creates the room:

Pho.Hashtable playerProps = PhotonNetwork.player.customProperties; playerProps.Add (UsernameKey.Value, username); PhotonNetwork.Player.SetCustomProperties (playerProps);

When another player connects, I simply grab the other player's custom properties but when I tried to read the username it doesn't seem to be in the hashtable.

Pho.Hashtable otherPlayerProps = PhotonNetwork.otherPlayers[0].customProperties; string otherPlayerUsername = otherPlayerProps[UsernameKey.Value]; // this is null

Any idea what could be going on here?

Comments

  • JohnTube
    JohnTube ✭✭✭✭✭
    Options
    Hi @czk,

    I think you can directly use PhotonPlayer.name and PhotonPlayer.userId.