PlayerRoomIndexing.cs utility script

Options
I am needing to identify players using the PlayerRoomIndexing.cs script for the classic version. I have attached the script to an empty game object in my scene, and from the scene view everything seems to work behind the scenes fine. But I need to find a way to check what player index each player has. I'm slightly confused as how it all works. How can I reference the player room indexing script (particularly the player index itself) in other scripts I have written.
For example, I need to say: if ( player index = 1){//then do this} (I know that isn't the right way to write it but could you please tell me what the right way is?
Thank you :)

Comments

  • JohnTube
    JohnTube ✭✭✭✭✭
    Options
    Hi @eel_eye_jar,

    Thank you for choosing Photon!

    You need to use player.GetPlayerNumber() to get player index/number, do not forget to add "using Photon.Pun.UtilityScripts;" on top of the file.
  • eel_eye_jar
    Options

    Thank you so much!

  • eel_eye_jar
    Options

    I just wanted to say JohnTube, your help here is amazing! I really appreciate it

  • eel_eye_jar
    Options

    Also, when I use Photon.Pun.UtilitySpcript ‘Pun’ is an error.

  • JohnTube
    JohnTube ✭✭✭✭✭
    Options
    when I use Photon.Pun.UtilitySpcript ‘Pun’ is an error.

    I see now.
    PlayerRoomIndexing is PUN Classic indeed.
    I thought you're using PlayerNumbering from PUN 2, my bad.

    Can you migrate to PUN 2?

    PlayerRoomIndexing namespace is ExitGames.UtilityScripts.
    the extension method is photonPlayer.GetRoomIndex();
  • eel_eye_jar
    Options

    My script does not recognise ‘photonPlayer’

  • eel_eye_jar
    Options

    Nevermind I have sorted it

  • eel_eye_jar
    Options

    How would I say ‘if photonPlayer.GetRoomIndex == 1’

  • eel_eye_jar
    Options
    Bump
  • eel_eye_jar
    Options
    Bump @JohnTube
  • Tobias
    Options
    Did you migrate to PUN 2?
    And please ask questions with intention. Let us know what you want to achieve, not the code that does not get you there.
  • eel_eye_jar
    Options
    No I have not migrated to pun 2. Do I need to? I want to achieve an if system where I can check what index number you are. Thank you
  • eel_eye_jar
    Options
    I am trying to create a system that says, if the players index is x, then do this. How can I check what index the local player has? Sorry if it seems like I'm being a tad annoying, I've been trying to fix this for a good couple of months now. Thank you.