How to know which photonView is the masterclient
The whole answer can be found below.
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).
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
Each player knows if they are the MasterClient or not, use: PhotonNetwork.IsMasterClient
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