- Home /
Photon Join room (Not Random Room)
hey gang just wondering how you join a room in photon (not joinrandomroom) but joint room with a name? Owner of the quest starts the room, other players joining the quest join his room :)
public string QuestName;
public string Username;
public bool IamTheOwner;
// Update is called once per frame
public void LeveOnMission () {
PhotonNetwork.Disconnect ();
}
void OnDisconnectedFromPhoton(){
LoadQuest ();
}
void LoadQuest(){
PhotonNetwork.autoJoinLobby = true; // we join randomly. always. no need to join a lobby to get the list of rooms.
PhotonNetwork.ConnectUsingSettings("EAO 0.1");
}
public void OnConnectedToMaster()
{
string RoomName = Username;
if (IamTheOwner == false) {
RoomOptions roomOptions = new RoomOptions () { isVisible = true, maxPlayers = 4};
Debug.Log ("OnPhotonRandomJoinFailed() was called by PUN. No random room available, so we create one. Calling: PhotonNetwork.CreateRoom(null, new RoomOptions() {maxPlayers = 4}, null);");
PhotonNetwork.JoinRoom(roomOptions);
}
if (IamTheOwner == true) {
RoomOptions roomOptions = new RoomOptions () { isVisible = true, maxPlayers = 4 };
Debug.Log ("OnPhotonRandomJoinFailed() was called by PUN. No random room available, so we create one. Calling: PhotonNetwork.CreateRoom(null, new RoomOptions() {maxPlayers = 4}, null);");
PhotonNetwork.CreateRoom (RoomName, roomOptions, TypedLobby.Default);
}
}
Answer by ChristianSimon · Dec 12, 2017 at 09:54 AM
Hi,
in PUN you can join a room by its name, for example: PhotonNetwork.JoinRoom("Room Name");
. You are currently using RoomOptions with JoinRoom function which won't work.
Hi! @ChristianSimon, I have a TextMeshProUGUI called EnterRoomName but it's not working. i was doing like this:
public void JoinRoom() {
PhotonNetwork.JoinRoom(EnterRoomName .text);
MenuManager.Instance.OpenMenu("loading");
}
Your answer
Follow this Question
Related Questions
Photon room name issue 0 Answers
Unity Photon Create a Passworded Room and join? 0 Answers
Unity photon network - game room 1 Answer
Multipalyer for a Room based game 1 Answer
Unity Photon Engine JoinOrCreateGame 2 Answers