Multiple master clients!

Options
Hello people and I hope everyone is in good health. I have just started following the tutorial for creating a multiplayer using Photon 2 on Unity. The problem that I have is that I seem to have multiple master clients. I am following the documentation for creating the game and I am currently at Demos and tutorials->PUN basic tutorials->4 - Game manager and level.

First I run an instance of the game on the Unity editor and then run a build on my pc. I hit play on the unity editor and I get all of the wonderful successful connection messages and whatnot. When I do the same thing on my other build, I see that the player name pop up as I have a debug message inside of public override void OnPlayerEnteredRoom(Player other);

This is basically the code:

public override void OnPlayerEnteredRoom(Player other)
{
Debug.LogFormat("OnPlayerEnteredRoom() {0}", other.NickName); // not seen if you're the player connecting

if (PhotonNetwork.IsMasterClient)
{
Debug.LogFormat("{0}, OnPlayerEnteredRoom IsMasterClient {1}", other.NickName,
PhotonNetwork.IsMasterClient); // called before OnPlayerLeftRoom
LoadArena();
}
}

The problem is, the second instance should not be the master client, correct? The Unity editor should be the master client and apparently it is, but when I connect the second client, I see a message go like '... True' the true standing form PhotonNetwork.IsMasterClient which is odd. This implies that the second build is also a master client and even the documentation says that the LoadLevel() method should only be called by the MasterClient and I can see the level load up twice which implies again, both the builds are master clients. Any help would be well appreciated. Thank you.

Comments

  • Federico123
    Options
    Can you please post it in code because i cannot understand the code
  • goduphi
    Options
    Yes, of course!
    public override void OnPlayerEnteredRoom(Player other)
    {
         Debug.LogFormat("OnPlayerEnteredRoom() {0}", other.NickName); // not seen if you're the player 
         connecting
    
         if (PhotonNetwork.IsMasterClient)
         {
              Debug.LogFormat("{0}, OnPlayerEnteredRoom IsMasterClient {1}", other.NickName,
              PhotonNetwork.IsMasterClient); // called before OnPlayerLeftRoom
              LoadArena();
         }
    }
    
  • S_Oliver
    S_Oliver ✭✭✭
    Options

    Are your editor and build in the same room?

  • goduphi
    goduphi
    edited April 2020
    Options
    I think they are as when I load one game, it automatically reloads the other. Is there an explicit way of forcing all of the clients to be in one room?
  • S_Oliver
    S_Oliver ✭✭✭
    Options

    One client creates a room the other joins room. Check out the pun 2 tutorials for that basic stuff.

  • goduphi
    Options
    I guess I'll re-read it because I probably did something wrong even though I tried to follow it to the point, but still getting this weird behavior. Thank you though.