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! Your search result can be found below. Plus, we offer support via these channels:

Try Our

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.

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

2019-03-18 22:21:00


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) {  

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


2019-03-18 23:00:38

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

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