How can I get player count in real time and the last player active in photon?

Hello, I am trying to get player count of all the current available players, i tried to use PhotonNetwork.CurrentRoom.PlayerCount, PhotonNetwork.CountOfPlayers, PhotonNetwork.PlayerList.Length but they dont get updated once a player is destroyed they still show the same amount of players when they first joined.

And the second question is how can i find the name of the last player active in game? like once all players are destroyed and 1 remains so i want that player name so that i can show him as the winner.

Answers

  • You mean players in the room you are in now? That's CurrentRoom.PlayerCount and this counts the clients connected to the room. It's not a count of arbitrary objects you destroy. Count that in your logic.

    The second question is also about your game logic.

    Maybe you take a look at the Asteroids Demo which is included in the PUN 2 package. It's a small game with logic that destroys the ships when hit, counts score and shows a winner. This is what you need.