OnJoinedRoom() is not called
Options
I'm trying to create PhotonConnection Manager script, it will receive room name and level name (game scene name) and then load it if a player has leaved current room. But OnJoinedRoom() is not called after OnConnectedToMaster() and OnJoinedLobby(). There's my script:
using System.Collections; using System.Collections.Generic; using UnityEngine; using Photon.Pun; public class ConnectionManager : MonoBehaviourPunCallbacks { public static string nextRoom; public static string nextLevel; public override void OnConnectedToMaster() { PhotonNetwork.JoinLobby(); } public override void OnJoinedLobby() { PhotonNetwork.JoinRoom(nextRoom); } public override void OnJoinedRoom() { PhotonNetwork.LoadLevel(nextLevel); } public override void OnJoinRandomFailed(short returnCode, string message) { base.OnJoinRandomFailed(returnCode, message); PhotonNetwork.CreateRoom(nextRoom); } public override void OnLeftRoom() { Debug.Log("Player leaving room"); } }
0
Answers
-
I think it's because you don't create a room, so you try to join the room "nextRoom" which is not created.
Try :
using System.Collections; using System.Collections.Generic; using UnityEngine; using Photon.Pun; public class ConnectionManager : MonoBehaviourPunCallbacks { public static string nextRoom; public static string nextLevel; public override void OnConnectedToMaster() { PhotonNetwork.JoinLobby(); } public override void OnJoinedLobby() { PhotonNetwork.JoinRoom(nextRoom); } public override void OnJoinedRoom() { PhotonNetwork.LoadLevel(nextLevel); } public override void OnJoinRoomFailed(short returnCode, string message) { PhotonNetwork.CreateRoom(nextRoom); } public override void OnLeftRoom() { Debug.Log("Player leaving room"); } }
Am I right ?
0 -
Don't join a lobby if you plan to join a specific room anyways. You can join an existing room (which is not full) just by the name alone.
0