Why OnJoinedRoom() Not Woking?

Options
Hello,

In the game, player 1 tries to join a random room, if fails creates a room, this is working perfectly. Player 2 tries to connect to random room, it connects and game starts, this is also working. The problem is, Player 2 does not enter the OnJoinedRoom() callback, I don't know why... Can you please help me? I coded all callbacks and none of them give any warning...
public void Connect()
    {
        Debug.Log("LauncherLog: Connect Function started.");
        isConnecting = true;
        GameObject.Find("MenuManager").GetComponent<MenuManager>().progressLabel.SetActive(true);
        GameObject.Find("MenuManager").GetComponent<MenuManager>().controlPanel.SetActive(false);
        
        if (PhotonNetwork.IsConnected)
        {
            Debug.Log("LauncherLog: Is connected to photon and will try to join random room.");
            PhotonNetwork.JoinRandomRoom();
        }
        else
        {
            Debug.Log("LauncherLog: Not Connected to Photon, reconnecting...");
            PhotonNetwork.GameVersion = gameVersion;
            PhotonNetwork.ConnectUsingSettings();
        }
    }

public override void OnJoinRandomFailed(short returnCode, string message)
    {
        Debug.Log("LauncherLog: Player join random room failed with error " + message);
        PhotonNetwork.CreateRoom(null, new RoomOptions { MaxPlayers = maxPlayersPerRoom});
    }

public override void OnJoinedRoom()
    {
        Debug.Log("LauncherLog: OnjoinedRoom Function started.");
        StartCoroutine(MoveToGameScene(2));
    }

private IEnumerator MoveToGameScene(int SceneIndex)
    {
        Debug.Log("LauncherLog: MoveToGameScene started.");
        PhotonNetwork.IsMessageQueueRunning = false;

        if (PhotonNetwork.IsMasterClient)
        {
            Debug.Log("LauncherLog: MoveToGameScene is master client!, will close room");
            PhotonNetwork.CurrentRoom.IsOpen = false; // I make it true, in the loaded scene.
            Debug.Log("Room closed");
        }

        LoadingScreenPro.LoadScene(SceneIndex);
        yield return null;
    }
PLAYER 1 LOG (Works perfectly):
LauncherLog: Connect Function started.
LauncherLog: Is connected to photon and will try to join random room.
LauncherLog: Player join random room failed with error No match found
LauncherLog: Player created room.
LauncherLog: OnjoinedRoom Function started.
LauncherLog: MoveToGameScene started.
LauncherLog: Is master client!, will close room
LauncherLog: LS-Pro LoadScene started with Scene No 2
LauncherLog: GameScene Started.
LauncherLog: Room Opened

PLAYER 2 LOG (Works strange...):
LauncherLog: Connect Function started.
LauncherLog: Is connected to photon and will try to join random room.
LauncherLog: GameScene Started.

Best Answer

Answers

  • Storm
    Storm
    edited April 2019
    Options
    Btw, I use following callbacks and I dont get any warning... I use PUN2 v2.9

    OnConnectedToMaster()
    OnJoinedLobby()
    OnLeftLobby()
    OnPlayerEnteredRoom(Player newPlayer)
    OnLeftRoom()
    OnJoinRoomFailed(short returnCode, string message)
    OnCreateRoomFailed(short returnCode, string message)
    OnCreatedRoom()
    OnDisconnected(DisconnectCause cause)
    OnPlayerLeftRoom(Player otherPlayer)
    OnJoinRandomFailed(short returnCode, string message)
    OnJoinedRoom()
  • Storm
    Options
    I found the problem, I was using a loading screen scene before the gamescene. I disabled the "autosyncscene" and problem solved. Thanks!
  • Urzathran
    Options

    I've come across a similar issue. My first couple callbacks work fine (OnConnectedToMaster(), OnJoinRandomFailed()), and the script keeps running with no errors after doing CreateRoom, but even with SupportLogger enabled, I get no callback for OnCreatedRoom, OnJoinedRoom, or even OnJoinRoomFailed.

    BUT! I did realize I was trying to do this for HTML5; when I rebuilt for PC Standalone, it works as expected. Do I need to change a setting somewhere to have it queue up for browser connecting?