How to know which photonView is the masterclient

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

  • Each player knows if they are the MasterClient or not, use: PhotonNetwork.IsMasterClient
  • JohnTube
    JohnTube ✭✭✭✭✭
    edited March 2019
    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