Actor Number
The whole answer can be found below.
Try Our
Documentation
Please check if you can find an answer in our extensive documentation on PUN.
Join Us
on Discord
Meet and talk to our staff and the entire Photon-Community via Discord.
Read More on
Stack Overflow
Find more information on Stack Overflow (for Circle members only).
Actor Number
Ehsan_AK
2020-07-08 07:10:41
Hello everyone,
I want to get list of players Respectively (Who Comes first, who comes second, ...), then I use PhotonNetwork.ActorNumber. but i notice that when there is no person in room and just one person enter room and leave the room, number of actor is 1(and this is correct) but (when there is two user in a room) another person from other pc joins the room and leave and again join the room, Actor number doesnt decrease and always increase. is this a bug? or is there any other solution?
Thanks
Comments
What are you using to get this "Actor Number"?
When a new player joins, they are given a new number, and numbers are not recycled.
So if player 1 forms a room, and player 2 joins.... then player 2 leaves...
the next person who joins will be given Actor Id of 3.
It isn't meant as a player count, it is just a unique id for each player that has joined.
Hi @Ehsan_AK,
Thank you for choosing Photon!
What you need is "Assets\Photon\PhotonUnityNetworking\UtilityScripts\PhotonPlayer\PlayerNumbering.cs".
It will give you player number per player use it instead of actor number.
SceneOfAction
2022-01-22 03:39:07
I've run into this issue. I found the script you referenced above @JohnTube , but I'm not sure how to implement it. Do I just put it on the component running the room? Thanks
Hi @SceneOfAction,
Thank you for choosing Photon!
Yes add the component to a GameObject in the scene preferably a one marked with DontDestroyOnLoad.
Or make use it exists as long as a player is in a room.
To use it you need to make use of extension method: Player.GetPlayerNumber()
.
Sorry for opening this ticket back up. But this 'Player.GetPlayerNumber()' is not working anymore in 2023. Or am I wrong?
EDIT:
PhotonNetwork.LocalPlayer.GetPlayerNumber()
Gives me -1
It is -1 if you are not in a room. It should be 1 and up, once you joined / created a room.
Back to top