photon wont connect

im using unity 2018.3.14f and pun 2. On connection, photon will get stuck at connectingtonameserver and nothing will happen afterwards, no connection is made... I have reinstalled photon, restarted computer, editor nothing is helping, its weird because this problem literally came out of nowhere and haven't been able to make progress.. Thank u!

this is my networking code that has worked before:

public static NB_Networking Instance;

[SerializeField] protected string Version = "0.1";
[SerializeField] protected GameObject Player = null;


private void Awake()
{
Instance = this;
DontDestroyOnLoad(gameObject);

ConnectToPhoton();
}

private void Update()
{
Debug.Log(PhotonNetwork.NetworkClientState);
}

public void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info)
{
}

protected virtual void ConnectToPhoton()
{
if((PhotonNetwork.IsConnected) || (PhotonNetwork.IsConnectedAndReady))
{
Debug.Log("Already connection to photon, returning so we dont reset our conection");
return;
}

try
{
PhotonNetwork.ConnectUsingSettings();

Debug.Log("Attemping Connection...");
}
catch
{
Debug.LogError("Couldn't connect to Photon Network");
}
}




public override void OnConnected()
{
base.OnConnected();

Debug.Log("cc");
}

public override void OnDisconnected(DisconnectCause cause)
{
base.OnDisconnected(cause);

Debug.Log(cause);
}


public override void OnConnectedToMaster()
{
Debug.Log("Succesfully connected to master");

PhotonNetwork.LocalPlayer.NickName = "Player " + Random.Range(0, 1000);
PhotonNetwork.JoinLobby();
}

public override void OnJoinedLobby()
{
base.OnJoinedLobby();

Debug.Log("Succesfully connected to lobby");

RoomOptions RoomOptions = new RoomOptions();
RoomOptions.CustomRoomProperties = new ExitGames.Client.Photon.Hashtable();

RoomOptions.CustomRoomProperties.Add("BlueScore", 0);
RoomOptions.CustomRoomProperties.Add("RedScore", 0);

PhotonNetwork.JoinOrCreateRoom("New Room", RoomOptions, null);
}

public override void OnJoinedRoom()
{
base.OnJoinedRoom();

Debug.Log("Succesfully joined room");

SpawnPlayer();
}

public void SpawnPlayer()
{
PhotonNetwork.Instantiate(Player.name, NB_Game.Instance.GetSpawnPoint().position, NB_Game.Instance.GetSpawnPoint().rotation, 0);
}

Comments

  • so i tried a new empty project with only pun 2 installed, it worked.. I have literally no idea what is causing this because as I said it worked hours before and now this is occuring with no changes..
Sign In or Register to comment.