Connection Problems.

When i click connect it says:
ConnectUsingSettings() failed. Can only connect while in state 'Disconnected'. Current state: Connected
UnityEngine.Debug:LogWarning(Object)
PhotonNetwork:ConnectUsingSettings(String) (at Assets/Photon Unity Networking/Plugins/PhotonNetwork/PhotonNetwork.cs:1165)
GameManager:Connect() (at Assets/Scripts/GameManager.cs:12)
GameManager:OnGUI() (at Assets/Scripts/GameManager.cs:48)
My code says:
using UnityEngine; using System.Collections; public class GameManager : Photon.MonoBehaviour { public GameObject[] redSpawns; public GameObject[] blueSpawns; public int state = 0; void Connect () { PhotonNetwork.ConnectUsingSettings ("V1.0"); } void OnJoinedLobby() { state = 1; } void OnPhotonRandomJoinedFailed() { PhotonNetwork.CreateRoom (null); } void OnJoinedRoom() { state = 2; } void Start () { } void Update () { } void OnGUI () { switch (state) { case 0: //STARTING SCREEN if (GUI.Button(new Rect(10, 10, 100, 30), "Connect")) { Connect (); } break; case 1: //CONNECTED TO SERVER GUI.Label(new Rect(10, 40, 100, 30), "Connected"); if (GUI.Button(new Rect(10, 10, 100, 30), "Search")) { PhotonNetwork.JoinRandomRoom(); } break; case 2: //CHANPION SELECT GUI.Label(new Rect(10, 40, 200, 30), "Select Your Champion"); if (GUI.Button(new Rect(70, 10, 100, 30), "Mojo")) { Spawn(0, "Mojo"); } break; case 3: //IN GAME break; } } void Spawn(int team, string character) { state = 3; Debug.Log("You are on team..." + team + ". And are playing as " + character); } }

Comments

  • vadimvadim ✭✭✭
    You probably call ConnectUsingSettings() twice, 2nd time when client is already connected. Log calls to find out how that could happen.
  • vadim said:

    You probably call ConnectUsingSettings() twice, 2nd time when client is already connected. Log calls to find out how that could happen.

    Yes but i need the button to change from connect to search
  • SwooSwoo
    I am having this same problem with that code. How can you make the code work without connecting twice?
Sign In or Register to comment.