- Home /
The question is answered, right answer was accepted
Photon Private Room Help
Hi there! Iv just started using Photon and im trying to create my own private room. So I started to use JoinOrCreateRoom but for some reason when the user is connecting to the server, it disconnects(this doesn't happen when joining a random room) Ill paste the code in where im getting the input field server name and the code im using to create the room. Thanks for any help in advance, much appreciated! This is the code when Creating/Joining a room and if it fails:
public override void OnConnectedToMaster()
{
if(isConnecting) //We dont want to do anything if we are not attempting to get a join a roomn
{
Debug.Log("Minutes2Meltdown/Launcher: OnConnectedToMaster was called by PUN");
PhotonNetwork.JoinOrCreateRoom(privateRoomName, new RoomOptions() { MaxPlayers = MaxPlayersPerRoom }, null); //First try to join a already existing room
}
}
public override void OnPhotonRandomJoinFailed(object[] codeAndMsg)
{
print("im here");
Debug.Log("Minutes2Meltdown/Launcher: No random room avaiable - need to create one");
//PhotonNetwork.CreateRoom(null, new RoomOptions() { MaxPlayers = MaxPlayersPerRoom }, null);
PhotonNetwork.JoinOrCreateRoom(privateRoomName, new RoomOptions() { MaxPlayers = MaxPlayersPerRoom }, null);
}
This is the code im using for the string input field:
public void AllocatePrivateServer(string serverName)
{
InputField _inputField = GameObject.Find("Server Name").GetComponent<InputField>();
if(_inputField != null)
{
_inputField.text = serverName;
privateRoomName = serverName;
}
}
Thanks again for any help!!
Edit: It seems to work now and all I done was re-open Unity...? Leaving it up in case anyone else wants to know how to create private rooms!
Follow this Question
Related Questions
photon marco polo tutorial issue with "peercreated" 1 Answer
Unity Photon Engine JoinOrCreateGame 2 Answers
Need help with joining a room in photon? 1 Answer
In Photon what is the difference between OnJoinedRoom() and OnPHotonPlayerConnected() 1 Answer
Unexpected Data Received - Photon Server, XmlSerializer and Unity 0 Answers