I took this example straight out of the documentation but it doesn’t actually let the client connect. My pc is port forwarded, I’m running 2 instances of the game, starting the server first, then the client on the other instance. It just prints “client.isConnected = False” every frame. Is it because I’m using the latest Beta? The scene is just 1 empty game object with this script attached. Do I need a NetworkIdentity somewhere?
import UnityEngine.Networking;
private var client : NetworkClient;
function Update(){
if(client) print(client.isConnected);
//be server
if(Input.GetKeyDown(KeyCode.S)){
NetworkServer.Listen(7777);
}
//be client
if(Input.GetKeyDown(KeyCode.C)){
client = new NetworkClient();
client.RegisterHandler(MsgType.Connect, ClientConnect);
client.Connect("127.0.0.1", 7777);
}
}
function ClientConnect(n : NetworkMessage){
print("ClientConnect");
}