Connection state stays on 'ConnectedToMaster'

Options
I am following the Marco Polo tutorial but my connection state stays on 'ConnectedToMaster', when the tutorial says it should say 'joined'.

Here is the code:

void Start () {

PhotonNetwork.logLevel = PhotonLogLevel.Full;

//Connect
PhotonNetwork.ConnectUsingSettings("v0.1");

}



public override void OnJoinedLobby()
{
PhotonNetwork.JoinRandomRoom();

}

void OnPhotonRandomJoinFailed()
{
Debug.Log("Can't join random room!");
PhotonNetwork.CreateRoom(null);
}

void OnGUI()
{
GUILayout.Label(PhotonNetwork.connectionStateDetailed.ToString());
}


}


Thanks for help!

Comments

  • Tobias
    Options
    If you use a more recent PUN version, it has another default value for "Auto Join Lobby" and will not call OnJoinedLobby.
    You have to find the PhotonServerSettings file and mark the checkbox "Auto Join Lobby".
    I will update the tutorial text accordingly. Sorry for making you run into this issue.

    See also: http://forum.photonengine.com/discussion/6426/
  • zigglr
    Options
    Tobias said:

    If you use a more recent PUN version, it has another default value for "Auto Join Lobby" and will not call OnJoinedLobby.
    You have to find the PhotonServerSettings file and mark the checkbox "Auto Join Lobby".
    I will update the tutorial text accordingly. Sorry for making you run into this issue.

    See also: http://forum.photonengine.com/discussion/6426/

    Thanks Tobias. Just one other thing to get me on my way, if you wouldn't mind. It seems that when I test multiplayer on 2 different computers, both computers will make their own room, rather than joining an existing room. Do you have any idea why? Here's the script:





    public override void OnJoinedLobby()
    {
    PhotonNetwork.JoinRandomRoom();
    }



    void OnPhotonRandomJoinFailed()
    {
    Debug.Log("Can't join random room!");
    RoomOptions roomOptions = new RoomOptions() { isVisible = false, maxPlayers = 2 };
    PhotonNetwork.CreateRoom(null, roomOptions, TypedLobby.Default);
    }





    public override void OnJoinedRoom()
    {
    if (PhotonNetwork.playerList.Length == 2)
    {
    Debug.Log("2 Players In Room Starting Level");
    PhotonNetwork.Instantiate(playerprefabname, spawner, spawnpoint.rotation, 0);
    }
    }
  • Tobias
    Tobias admin
    edited October 2015
    Options
    Our preferred workflow is described here:
    https://doc.photonengine.com/en/pun/current/tutorials/matchmaking-and-lobby

    It's implemented in a script in PUN. Use the ConnectAndJoinRandom script as basis.

    Please note: When your only 2 clients try to join a room at the same time, both will create one and wait for others to join. At debug time, you should start the 2 clients with a slight delay.
    Alternatively, you could make up a fixed debug room name and use JoinOrCreateRoom instead.
  • zigglr
    Options
    Tobias said:

    Our preferred workflow is described here:
    https://doc.photonengine.com/en/pun/current/tutorials/matchmaking-and-lobby

    It's implemented in a script in PUN. Use the ConnectAndJoinRandom script as basis.

    Please note: When your only 2 clients try to join a room at the same time, both will create one and wait for others to join. At debug time, you should start the 2 clients with a slight delay.
    Alternatively, you could make up a fixed debug room name and use JoinOrCreateRoom instead.

    Great thanks