I cannot seem to get the unity networking thing to work correctly. When I start a start a server and try to connect to it, it gives me the error: NAT target 127 not connected to NAT facilitator 25.181.197.205:50005. I have searched all over unity answers for the fix. I tried creating my own master server and facilitator, turning NAT off, and changing the connection IP to various other IP addresses that may have worked, all to no avail. Please, if anyone has fixed this problem share your solution.
Here is my server and client code:
if (Network.peerType == NetworkPeerType.Disconnected) {
// host server
hostName = GUI.TextField(new Rect(Screen.width * 0.7f, Screen.height * 0.7f - Screen.height/10 - 60, Screen.width/7, 20), hostName);
GUI.Label(new Rect(Screen.width * 0.7f - 41, Screen.height * 0.7f - Screen.height/10 - 60, Screen.width/7, 20), "Name: ");
comment = GUI.TextField(new Rect(Screen.width * 0.7f, Screen.height * 0.7f - Screen.height/10 - 40, Screen.width/7, 20), comment);
GUI.Label(new Rect(Screen.width * 0.7f - 63, Screen.height * 0.7f - Screen.height/10 - 40, Screen.width/7 + 63, 20), "Comment: ");
connections = GUI.TextField(new Rect(Screen.width * 0.7f, Screen.height * 0.7f - Screen.height/10 - 20, Screen.width/7, 20), connections);
GUI.Label(new Rect(Screen.width * 0.7f - 80, Screen.height * 0.7f - Screen.height/10 - 20, Screen.width/7 + 100, 20), "Max Players: ");
port = GUI.TextField(new Rect(Screen.width * 0.7f, Screen.height * 0.7f - Screen.height/10, Screen.width/7, 20), port);
GUI.Label(new Rect(Screen.width * 0.7f - 30, Screen.height * 0.7f - Screen.height/10, Screen.width/7, 20), "Port: ");
try {
port1 = int.Parse(port);
connections1 = int.Parse(connections);
} catch {
GUI.Label(new Rect(Screen.width * 0.7f + 100, Screen.height * 0.6f - Screen.height/10 - 20, Screen.width/10, 80), "Port and Max Players Must be Integers");
}
if (GUI.Button(new Rect(Screen.width * 0.7f, Screen.height * 0.7f, Screen.width/5, Screen.height/5), "Make Server")) {
Network.InitializeServer(connections1, port1, true);
}
// join server
portToConnect = GUI.TextField(new Rect(Screen.width * 0.2f, Screen.height * 0.7f - Screen.height/10, Screen.width/7, 20), portToConnect);
GUI.Label(new Rect(Screen.width * 0.2f - 30, Screen.height * 0.7f - Screen.height/10, Screen.width/7, 20), "Port: ");
ip = GUI.TextField(new Rect(Screen.width * 0.2f, Screen.height * 0.7f - Screen.height/10 - 20, Screen.width/7, 20), ip);
GUI.Label(new Rect(Screen.width * 0.2f - 20, Screen.height * 0.7f - Screen.height/10 - 20, Screen.width/7, 20), "IP: ");
if (GUI.Button(new Rect(Screen.width * 0.15f, Screen.height * 0.7f, Screen.width/5, Screen.height/5), "Join Server")) {
try {
Network.Connect(ip, portToConnect);
} catch {
failed = true;
}
}
if (failed) {
GUI.Label(new Rect(Screen.width * 0.2f - 30 - 50, Screen.height * 0.7f - Screen.height/10, Screen.width/7, 20), "Unknown Server");
Debug.Log("Failed");
}
}