- Home /
Network.player.externalIP returning localIP
Hey there i'm just fooling around with the Network system of unity. And yesterday i was working on my laptop and made a connecting and hosting part and it would write my externalIP on the console. works perfectly builded it connected to the external ip of my laptop.
Now i'm on my work computer and i tried the same project on there though it doesnt seem to work at all it will either return my LocalIP or 'UNNASIGNED_SYSTEM_ADDRES'
Any help is appreciated tnx.
Things i've tried on my computer :
Opening port on router and Turning off firewall
Even tough my laptop has its firewall on and no portforwarded ports on it
How am i connecting / creating network
public void HostServer() { bool useNat = !Network.HavePublicAddress(); Network.InitializeServer(2, 25080, useNat); }
void OnServerInitialized()
{
Debug.Log ("Created on IP:" + Network.player.externalIP + " Port:" + Network.player.externalPort);
Application.LoadLevel("LobbyMP");
}
public void JoinServer(Text text)
{
Network.Connect(text.text, 25080);
Debug.Log (text.text);
}
void OnConnectedToServer()
{
//Connected to a server
Application.LoadLevel("LobbyMP");
}
Tried a few times on my laptop turned firewall on and off.
the one time it gives localIP the other time it returns externalIP (Network.player.externalIP)
Tried connecting from laptop to pc i can connect locally but not trough externalIP i check with openportcheck tool to check if the port was opened and its not any help ?
Answer by ExtremePowers · Mar 20, 2015 at 05:19 PM
That might be because you are connected locally to the server. AFAIK You can't connect to your own server if it is on the same computer.
Then how is it that my laptop does get its externalIP from itself and CAN connect to itself using its externalIP, And my computer cant ?
Have you tried on your laptop again, it could be something you changed in between..
Yes i tried during the test on my computer and it still works on my laptop
Answer by XerosDylan · Mar 20, 2015 at 06:15 PM
Asked a current Unity Developer on my skype list he got me some information about this and basicly to just get ExternalIP from myself would be doing the code below before starting the server.
Network.Connect("www.google.com"); string externalIP = Network.player.externalIP; Network.Dissconenct();
Also if i'd want people to connect to it they would have to port forward or i'd have to setup UPNP theres a asset called 'TNET' that does this for me.
Conclusion : If you want just LAN Multiplayer server this could be perfectly fine. If you'd wanna share it with online friends use a provider like Hamachi or Tunngle.
Making it with an externalIP means that the host player has to portforward
Your answer
Follow this Question
Related Questions
What is the CCU of the default Unity Networking? 1 Answer
Unity Web Request 2 Answers
How to Sync a sprite change to other clients? 0 Answers
Can I add a network prefab at runtime? 1 Answer
Instantiate By ID? 0 Answers