PhotonNetwork.SetMasterClient() not working
Options
Hello,
I am trying to understand why the Master Client doesn't switch when I call SetMasterClient.
I have two Android mobile devices. They run the same code apart from one bool variable which I use to distinguish between the two.
I tell one of the two to set itself as master client by doing a check on that bool variable but although SetMasterClient returns true, the network doesn't acknowledge the switch
I also tried to turn this into an RPC which I call on the master client from another client as I thought maybe only the master client can force a mnual switch but the result doesn't change.
What am I doing wrong?
Many thanks!
I am trying to understand why the Master Client doesn't switch when I call SetMasterClient.
I have two Android mobile devices. They run the same code apart from one bool variable which I use to distinguish between the two.
I tell one of the two to set itself as master client by doing a check on that bool variable but although SetMasterClient returns true, the network doesn't acknowledge the switch
if (_Kwesi != null) { bool _success = PhotonNetwork.SetMasterClient(PhotonNetwork.LocalPlayer); Debug.LogWarning($"Local player Nickname: {PhotonNetwork.LocalPlayer.NickName}, Actor Number: {PhotonNetwork.LocalPlayer.ActorNumber}, IsMasyer: {PhotonNetwork.LocalPlayer.IsMasterClient}, UserID: {PhotonNetwork.LocalPlayer.UserId}"); if (_success) { Debug.Log($"I have assigned the master client to the !autoconnect player. Outcome: {_success}"); Debug.Log($"AM I THE MASTER CLIENT? = {PhotonNetwork.IsMasterClient}"); //THIS ALWAYS RETURNS FALSE even if it should have switched } } else { Debug.LogError("Failed to assign master client to Kwesi"); } }
I also tried to turn this into an RPC which I call on the master client from another client as I thought maybe only the master client can force a mnual switch but the result doesn't change.
What am I doing wrong?
Many thanks!
0
Comments
-
I found out what the problem was, I wasn't waiting enough time for the master client to switch. Implementing the OnMasterClientSwitched callback clarified when the event occurred. I found this youtube clip helpful https://www.youtube.com/watch?v=yrB7Hyh2BE4&ab_channel=FirstGearGames0