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

Options
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!

Best Answer

  • JohnTube
    JohnTube ✭✭✭✭✭
    edited July 2020 Answer ✓
    Options
    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.

Answers

  • JohnTube
    JohnTube ✭✭✭✭✭
    Options

    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
    Options
    @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
    JohnTube ✭✭✭✭✭
    edited July 2020 Answer ✓
    Options
    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
    Options
    Oh thanks! Do you know where i can find out if it is 0 or 1 because I'm making a switch case?
  • JohnTube
    JohnTube ✭✭✭✭✭
    Options
    I checked PlayerNumbering code, I think it starts with 0.
  • Chr0my
    Options
    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
    Options
    @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!!!