How to identify our own player ?

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.

How to identify our own player ?

Steve
2020-04-13 11:50:54

I need to indentify each players because I want to Initialise each Player in a different location. I tried to use the LocalPlayer but when I look into the LocalPlayer, every player has the same UserID, ActorNumber, NickName etc...
I also tried the PlayerNumbering, it doesn't seem to work either. I didn't find any other informations in the documentation.

Comments

JohnTube
2020-04-13 13:28:07

Hi @Steve,

Thank you for choosing Photon!

Player.IsLocal  
PhotonView.IsMine  
PhotonNetwork.LocalPlayer

I tried to use the LocalPlayer but when I look into the LocalPlayer, every player has

Why do you need to look at every player if you have LocalPlayer? LocalPlayer is a single unique player not many.

every player has the same UserID, ActorNumber

This is not possible in the same room.

I think maybe the issue you are having is that you are testing on different clients and clients are joined to different rooms. If it's the case make sure clients are joined to the same room. See "Matchmaking Checklist". If it's not the case then there is something wrong with your code and share your snippet here and what you have tried exactly + PUN version.

NaBUru38
2020-04-13 15:21:04

Before connecting to the Photon servers, set the value of PhotonNetwork.NickName to some random string.

Once you joined a room, check PhotonNetwork.PlayerList to see which players are in that room.

Back to top