The Photon Forum
is Closed Permanently.

After many dedicated years of service, we have made the decision to retire our Forum and switch to read-only: we´ve saved the best to last! Your search result can be found below. Plus, we offer support via these channels:

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).

Write Us
an E-Mail

Feel free to send your question directly to our developers.

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

emotitron
2020-07-08 12:24:40

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.

JohnTube
2020-07-08 12:59:26

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

JohnTube
2022-01-22 06:16:07

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() .

RocketCis
2023-03-20 13:15:55

Sorry for opening this ticket back up. But this 'Player.GetPlayerNumber()' is not working anymore in 2023. Or am I wrong?

EDIT:

Gives me -1

Tobias
2023-03-21 11:22:04

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