PlayerRoomIndexing.cs utility script

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 ✭✭✭✭✭
    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.
  • Thank you so much!

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

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

  • JohnTube
    JohnTube ✭✭✭✭✭
    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();
  • My script does not recognise ‘photonPlayer’

  • Nevermind I have sorted it

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

  • Bump
  • 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.
  • 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
  • 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.