Set opponent nickname

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.

Set opponent nickname

sic_architect
2021-05-05 17:49:47

I created a game with 2 players (online). I would like to add nicknames. I added the owner nickname it was simple but how to add the opponent nickname without using the array?

https://paste.myst.rs/1vlwtrsa

Comments

JohnTube
2021-05-06 03:30:46

Hi @sic_architect,

Thank you for choosing Photon!

Player Nickname is a player property that is automatically synchronized between players joined to the same room so no need to synchronize it via RPC!
Simply set the Nickname of the local player and all other players joined to the same room will get it updated.

sic_architect
2021-05-06 16:31:31

I set local player name, but How Can I separate both?

JohnTube
2021-05-09 10:42:20

Hi @sic_architect,

Simply make use of player.IsLocal or photonView.IsMine etc. to know if a player is local or not.
And when you set Nickname set it to the local player only: PhotonNetwork.LocalPlayer.Nickname.

Back to top