how to fix onConnectedToMaster not calling

Options

im attempting to create crossplatform play with oculus and pc but i cant connect to the server and im stuck on the loading screen

this is my script

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Photon.Pun;
using UnityEngine.SceneManagement;
public class ServerLoader : MonoBehaviourPunCallbacks
{
    void Start()
    {
        Debug.Log("attempting to connect");
        PhotonNetwork.ConnectUsingSettings();
        Debug.Log("Connected once");
    }

    public override void OnConnectedToMaster()
    {
        Debug.Log("Connected twice");
        if(Application.platform == RuntimePlatform.WindowsPlayer)
        {   
            Debug.Log("attempting join lobby");
            PhotonNetwork.JoinLobby();
            Debug.Log("Joining lobby");
        }    
        else if(Application.platform == RuntimePlatform.Android)
            PhotonNetwork.CreateRoom(RandomStringGenerator(6));
            Debug.Log("Joining game");
    }

    public override void OnJoinedRoom()
    {
    PhotonNetwork.LoadLevel("Game");
    }

    public override void OnJoinedLobby()
    {
        SceneManager.LoadScene("Lobby");
    }

        string RandomStringGenerator(int length)
    {
        string characters = "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890";
        string generated_string = "";

        for(int i = 0; i < length; i++)
            generated_string += characters[Random.Range(0, length)];

        return generated_string;
    }
}

the only logs that get printed in the output are "attempting to connect" and "connected once"

Answers

  • Tobias
    Tobias admin
    edited February 2023
    Options

    Increase the Network Level Logging and enable the SupportLogger.

    Check if you need to set "Capabilities" for the device to be allowed to use the internet, etc.

    In general, PUN and other Photon SDKs work just fine on mobile.