Scoreboard help
Options
Hello!
Im new to this forum and new to Photon networking with Unity so don't hate if I have or will do anything terribly wrong.
What I want to do is a scoreboard for my multiplayer game that will display Deaths kills etc for each player.
I want the final code "output" to be like this:
So, the question is: How do I add another variable to the PhotonPlayer class like "PlayerName" becasue "Playername" updates in real time during gameplay and every client recieves the new name, but I want to add "Kills" and "Deaths". I dont want to do RPC calls for this..
Thanks for any help, I may have been unclear but reply if anything seems blurry.
Im new to this forum and new to Photon networking with Unity so don't hate if I have or will do anything terribly wrong.
What I want to do is a scoreboard for my multiplayer game that will display Deaths kills etc for each player.
I want the final code "output" to be like this:
if (ShowScoreBoard) { GUILayout.BeginArea(new Rect(Screen.width/4,Screen.height/2,Screen.width/2,Screen.height/2),GUIStyle.none); foreach(PhotonPlayer player in PhotonNetwork.playerList) { GUILayout.Label(player.name + " Kills: " + player.kills.ToString() + " Deaths: " + player.Deaths.ToString()); } GUILayout.EndArea(); }
So, the question is: How do I add another variable to the PhotonPlayer class like "PlayerName" becasue "Playername" updates in real time during gameplay and every client recieves the new name, but I want to add "Kills" and "Deaths". I dont want to do RPC calls for this..
Thanks for any help, I may have been unclear but reply if anything seems blurry.
0
Comments
-
Use PhotonNetwork.SetPlayerCustomProperties(new Hashtable() { { "kills", x }, ... }) for adding or updating custom properties of local player and player.customProperties["kills"] for getting custom property of any player.
That should be enough for sample above but for some other scenarios also handling PhotonNetworkingMessage.OnPhotonPlayerPropertiesChanged may make sense.0