Check if Client

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.

Check if Client

SullyBully
2019-07-14 11:06:49

So in my game, when I finished putting photon views on everything, and when I tested out the game, I could control the two players with the same controls!
In uNET, all I had to do was check "localPlayer" and that would fix everything.

Is there anyway to do this with PUN?

Comments

SullyBully
2019-07-14 11:21:18

Edit: I got it to work by using "if (!PhotonNetwork.LocalPlayer.IsLocal)
return;"

develax
2019-07-14 14:03:15

Hi @SullyBully,
if your class inherits from <i class="Italic">MonoBehaviourPun</i> you can use

bool isLocal = photonView.IsMine || !PhotonNetwork.IsConnected;

<i class="Italic">!PhotonNetwork.IsConnected</i> is there for the case when you want to run your map without connecting to the server.

Back to top