What is the ActorNumber/UserID naming scheme and clashing numbers?

The whole answer can be found below.

Please note: 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! And we offer you support through 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.

What is the ActorNumber/UserID naming scheme and clashing numbers?

Chr0my
2020-07-19 02:07:15

Hi!
I have a 10 player lobby. I want to assign each player something, but I need to know the actornumber scheme. Is it just 0, 1, 2, 3, etc? or?

or

How can I make all the actor numbers +1 from 0?

also

Can there be 2 of the same actor numbers? if so any way to get a new number and how can you detect a clash?
thanks!

Comments

JohnTube
2020-07-19 22:35:24

Hi @Chr0my,

You probably need player number or player index instead of actor number.
Read more here: https://forum.photonengine.com/discussion/comment/46285/#Comment_46285
and here
https://forum.photonengine.com/discussion/comment/51921/#Comment_51921

Chr0my
2020-07-21 11:05:05

@JohnTube

So for the player index - is it guaranteed that it will be +1 and that host is 1? i want to make a switch function.

JohnTube
2020-07-21 11:41:19

There is no host in Photon.
There is master client.

Master client can change.

If you mean room creator, initial master client, then yes if it's still in the room it will always have actor number 1 and player index (0 or 1) not sure what is the initial value used.

In any case, whether you use actor number or else, it also depends on your game, if it allows drops/disconnects and rejoins or if it allows late joins, etc.

Chr0my
2020-07-21 15:19:44

Oh thanks! Do you know where i can find out if it is 0 or 1 because I'm making a switch case?

JohnTube
2020-07-21 16:02:13

I checked PlayerNumbering code, I think it starts with 0.

Chr0my
2020-07-21 16:55:57

Last question:

Will this work?

            switch (PhotonNetwork.LocalPlayer.GetPlayerNumber())  
            {  
                case '0':  
                    Debug.Log("0");  
                    photonView.RPC("RPC_NickName", RpcTarget.All, nickName);  
                    break;  
                case '1':  
                    Debug.Log("1");  
                    photonView.RPC("RPC_NickName1", RpcTarget.All, nickName1);  
                    break;  
//ect players  
           }  

If not could you show me just a quick example of what would?

Chr0my
2020-07-21 18:38:19

@JohnTube

^ (sorry i cant test the code, just wanted to know theoretically if it would work)

Anyway thank you so much for all the help!!!

Back to top