Having errors when I added a function in the RPSCore.
Options
I added
and now im currently having these errors..
can someone help me please.. Thanks
EnemyHP.value = EnemyHP.value - local.GetScore ();
in the RPSCore code.
public void UpdatePlayerTexts() { PhotonPlayer remote = PhotonNetwork.player.GetNext(); PhotonPlayer local = PhotonNetwork.player; if (remote != null) { // should be this format: "name 00" this.RemotePlayerText.text = remote.name + " " + remote.GetScore().ToString("D2"); EnemyHP.value = EnemyHP.value - local.GetScore (); } else { TimerFillImage.anchorMax = new Vector2(0f,1f); this.TimeText.text = ""; this.RemotePlayerText.text = "waiting for another player 00"; } if (local != null) { // should be this format: "YOU 00" this.LocalPlayerText.text = "YOU " + local.GetScore().ToString("D2"); PlayerHP.value = PlayerHP.value - remote.GetScore (); } }
and now im currently having these errors..
NullReferenceException: Object reference not set to an instance of an object
ScoreExtensions.GetScore (.PhotonPlayer player) (at Assets/Photon Unity Networking/UtilityScripts/PunPlayerScores.cs:35)
RpsCore.UpdatePlayerTexts () (at Assets/Photon Unity Networking/Demos/DemoRockPaperScissors/Scripts/RpsCore.cs:429)
RpsCore.Update () (at Assets/Photon Unity Networking/Demos/DemoRockPaperScissors/Scripts/RpsCore.cs:182)
ScoreExtensions.GetScore (.PhotonPlayer player) (at Assets/Photon Unity Networking/UtilityScripts/PunPlayerScores.cs:35)
RpsCore.UpdatePlayerTexts () (at Assets/Photon Unity Networking/Demos/DemoRockPaperScissors/Scripts/RpsCore.cs:429)
RpsCore.Update () (at Assets/Photon Unity Networking/Demos/DemoRockPaperScissors/Scripts/RpsCore.cs:182)
can someone help me please.. Thanks
0
Comments
-
Hi,
Your photonPlayer pointer is null. So before you call GetScore, check that it's not null, else, put a log. It's likely your remote player that is null.
Bye,
Jean0 -
So that just means that there are no other players connected in the lobby with me?0
-
You should check with PhotonNetwork.countOfPlayers and PhotonNetwork.countOfPlayersInRoom for this.
Bye,
Jean0