How to know which photonView is the masterclient

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 know which photonView is the masterclient

dreadlocks
2019-03-18 22:21:00

Hello,

I need to know which player is the master client, so my code looks like this

        GameObject[] players = GameObject.FindGameObjectsWithTag("Player");  
        foreach (GameObject p in players) {  
            PhotonView pv = p.GetComponent (PhotonView)();  
            if (pv.isMasterClient) {  
                  pv.RPC("myfunction",......);  
            }  
        }

but photonView doesnt have isMasterClient on there. How can i know if a particular photonview is the master client?

Comments

Breeman
2019-03-18 23:00:38

Each player knows if they are the MasterClient or not, use: PhotonNetwork.IsMasterClient

JohnTube
2019-03-19 10:32:54

Hi @dreadlocks,

As @Breeman wanted to say, I think there are easier ways to know who's the master client than doing an expensive FindGameObjectsWithTag() call.

replace pv.isMasterClient

with pv.Owner.IsMasterClient

Back to top