1

In Unity's new networking, I have two computers side by side on the same WiFi network.

Using NetworkManager, I am trying to network them over the LAN.

TBC, absolutely nothing to do with global internet networking, and not on localhost.

enter image description here

On the left is 192.168.0.26.

On the right is on 192.168.0.120.

Say we want the left one to be the server, i.e. simply using

    Debug.Log("I'm now a server");
    networkManager.StartServer();

Say we want the right one to be a client (So, StartClient() .)

TBC I simply looked at ipConfig/etc on the two computers, to get the current local IP.

I absolutely ensured both machines have the firewall open for Unity editor (an infuriating gotchya).

In fact, which "NetworkAddress" (see image) do you use? On the two machines?

There are four permutations.

I just cannot get them to connect over LAN - what should the network address be?


Footnote: For anyone googling here be aware of this critical tip about Unet ... https://stackoverflow.com/a/51759299/294884

Cœur
  • 37,241
  • 25
  • 195
  • 267
Fattie
  • 27,874
  • 70
  • 431
  • 719
  • Server(Mac) side should put localhost or 192.168.0.26. Client(PC) should put the ip of server, also 192.168.0.26. – siusiulala Jul 17 '18 at 03:20
  • localhost is totally wrong. Sorry. – Fattie Jul 17 '18 at 03:44
  • 1
    First of all, every instance (client/server) should have the same IP address. Also if you think about it if you make an instance of the client, and he does not know the IP of the server, how could he connect? And last, you should use the locally assigned IP address (by the router) of the server machine, in your case `192.168.0.26`. I recommend using the `networkManager.StartHost();` instead of the `networkManager.StartServer();` since your server perhaps also needs a client. If that's not the case ignore this. – Hristo Jul 17 '18 at 05:50
  • 1
    hi @Hristo - clear explanation, I will try it ! – Fattie Jul 17 '18 at 10:41
  • If you are still having issues connecting, consider switching the client/server from Mac/PC, since I have no clue if Mac has a firewall that will prevent server generation. – Hristo Jul 17 '18 at 11:21
  • Massive bounty here – Fattie Jul 22 '18 at 01:03

1 Answers1

5

Wen using the default Network Manager provided by Unity, you have to make sure the Network Address field contains the local IP (provided by your router) of the machine you want to use as a server. In your case this IP is equal to 192.168.0.26 and can be found in the network configuration of the machine.
Every instance of client/server must use this IP address from now on in order to know where to connect to.

Something I personally recommend when creating the server is using the networkManager.StartHost(); instead of the networkManager.StartServer(); since your server perhaps also needs a client. If that's not the case please ignore this statement.

And lastly if you are up to the task, you can consider making your own Custom Networking Manager that inherits from the Network Manager. That way you could be in control of your app's networking even more.

Hristo
  • 1,805
  • 12
  • 21
  • 2
    This is the answer! :) – Fattie Jul 18 '18 at 15:00
  • @Fattie Thanks! – Hristo Jul 22 '18 at 14:56
  • 1
    thank YOU . interesting nobody has been able to answer this one .. https://stackoverflow.com/questions/51381964 .. I guess as you say the answer is simply "no, it is not possible" :/ – Fattie Jul 22 '18 at 15:04
  • @Fattie Not necessarily, I have a project I'm working on with networking I will make a test tomorrow hopefully and if I get any results I will post them as a concrete answer. – Hristo Jul 22 '18 at 21:55