ConnectUsingSettings Error

Options
Hello,
I'm very new to programming and I have purchased an MMO kit to help speed up development of my game.
It came with a basic template of a NetworkManager.cs script, Currently I'm unable to set it up to use PUN.


using System.Collections;
using System.Collections.Generic;
using UnityEngine;

///
/// This scirpt is used to connect and check if we are connected before start loading PHP scripts, this is only a template due we don't connect to any server.
///
public class NetworkManager : MonoBehaviour {


public bool connected; //Boolean that checks if we are connected to a server.

public Message _message; //A reference to our Message script

public string serverIP = "XXX.X.X.X"; //Server IP that will change by calling the "SelectServer" method from a button.

public GameObject[] ToEnableWhenConnect; //An Array of GameObject that must be enabled we've just connected to a server
public GameObject[] ToDisableWhenConnect; //The same, but this time the GameObject must be disabled!


private void Awake()
{
DontDestroyOnLoad(gameObject);
}

//This method is called by a UI button with the Server name and Server info.
public void SelectServer(string IP)
{
serverIP = IP;
}


//This method gonna be called when we press "Continue" from the server list.
public void SelectionServerContinue()
{
_message.gameObject.SetActive(true); //Poup up the message
_message.ChangeMessage("Connecting..."); //Change the message text

//Connect to the server with the ServerIP

PhotonNetwork.ConnectUsingSettings ("1.0.0");


if (connected)
{
//if we are connected, enable what we have to enable and disable what we have to disable
for (int i = 0; i < ToEnableWhenConnect.Length; i++)
{
ToEnableWhenConnect[i].SetActive(true);
}
for (int i = 0; i < ToDisableWhenConnect.Length; i++)
{
ToDisableWhenConnect[i].SetActive(false);
}
}
else //otherwise there was a problem with the connection, throw an error
{
_message.gameObject.SetActive(true);
_message.ChangeMessage("Could not reach this server, please check your connection and retry.");
return;
}
}


}

END OF CODE
This gives me the error ConnectUsingSettings failed. Can only connect while in state 'Disconnected'.
This is probably a newbie error but I'm terrible with networking :disappointed:

Thanks for the help!

Comments

  • Hi @jeremy,

    which MMO Kit is this? I'm asking because I think that this isn't one of ours, so supporting this might be out of range for us.

    To the problem itself: this error message states that you already tried to connect to Photon before and therefore the state is not 'Disconnected' any longer. If the state is not 'Disconnected', ConnectUsingSettings(...) won't work.