Loading levels when not Master Client
Options
I know, I know, it can't be done. But hear me out.
I have a game - let's call it tennis. Each player takes turns "serving", and can score points on each and every turn. First one to 11 wins the set, and we change scenes to a new stadium.
If the Master Client wins, everything works great. But if the other player in the room (and there can only ever be 2) wins, I need to change scenes immediately and can't figure out how to do it. I tried using SetMasterClient but that didn't work. I moved my LoadScene call into the area of code that gets called at the beginning of each turn. For some reason, when I check, the ActorNumber of the player is 1 (the Master Client), but when it gets to LoadScene, the player has reverted back to Player Two and I get my trusty message "trying to load a scene while not the Master Client!".
This has to be easy. I know I'm missing something obvious. Can someone give me a push in the right direction?
Thanks in advance...
I have a game - let's call it tennis. Each player takes turns "serving", and can score points on each and every turn. First one to 11 wins the set, and we change scenes to a new stadium.
If the Master Client wins, everything works great. But if the other player in the room (and there can only ever be 2) wins, I need to change scenes immediately and can't figure out how to do it. I tried using SetMasterClient but that didn't work. I moved my LoadScene call into the area of code that gets called at the beginning of each turn. For some reason, when I check, the ActorNumber of the player is 1 (the Master Client), but when it gets to LoadScene, the player has reverted back to Player Two and I get my trusty message "trying to load a scene while not the Master Client!".
This has to be easy. I know I'm missing something obvious. Can someone give me a push in the right direction?
Thanks in advance...
0
Comments
-
Here's my code:
if(!PhotonNetwork.IsMasterClient){ Debug.Log("Master Client is: " + PhotonNetwork.MasterClient); Debug.Log("Local Player is " + PhotonNetwork.LocalPlayer + ". Trying to set as master client."); PhotonNetwork.SetMasterClient(PhotonNetwork.LocalPlayer); Debug.Log("Master Client is: " + PhotonNetwork.MasterClient); Debug.Log("Trying to load a level but not master client. Oops!"); }
and the debug log says (loosely, not character for character:
Master Client is Master
Local Player is Editor. Trying to set as master client.
Master Client is Master
Trying to load a level but not master client....
I'm really at a loss...
0 -
Well, this got me more than halfway there:
[url]="https://stackoverflow.com/questions/37743191/when-to-use-photon-networking-master-client"[/url]
"When implementing game logic, use PhotonNetwork.isMasterClient property to check if current client is a master. If you want to trigger some action from non-master client, simply send RPC to a master asking it to do an action."
So that's what I did... the scenes are now switching no matter who wins, although there's some other weird behavior I'll have to debug later. Good night!0