Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

How to setup NetworkDiscovery component for LAN?

Discussion in 'Multiplayer' started by Bigbeef, Apr 6, 2017.

  1. Bigbeef

    Bigbeef

    Joined:
    Apr 6, 2013
    Posts:
    31
    Utilizing the NetworkManager, NetworkManagerHUD, and NetworkDiscovery components I have no problem connecting when two instances of the game are running on the same computer, but when I try to connect over the LAN between 2 computers, it fails. Even though the NetworkDiscovery GUI discovers the host computer and pops up a button showing the IPaddress of the host game, when I click it, it fails to connect!

    Over the network if I simply type in the IP Address manually into the NetworkManagerHUD box (to the right of the Client connect button), everything works, even over the network.

    I think there's something wrong with my NetworkDiscovery component attributes I think. Any advice would be great.

    1. I host game on 1 instance by pressing the "Host" button.
    2. I press NetworkDiscovery Instantiate button -> then click the Broadcast Server button

    3. I go to my other machine running the game on my LAN.
    4. Run the game -> press Instantiate button on my NetworkDiscoveryGUI -> press Listen button
    5. I see a button pop up displaying the IPAddress of the Host machine
    6. I click it, nothing happens, it fails to connect.

    If I run the game twice, 2 instances, on one machine, the network discovery works perfectly. Host one, broadcast, swap to other instance of the game running, click listen, see the ipaddress button appear, click it, it connects and game works perfectly.

    Any idea if I have to adjust any of my LAN settings? or if my NetworkDiscovery component attributes / NetworkManager component attributes need to be changed from the stock settings for it to work over the LAN?
     
  2. aabramychev

    aabramychev

    Unity Technologies

    Joined:
    Jul 17, 2012
    Posts:
    574
    could you please run ipconfig/all or ifconfig (if you on mac), actually I'm interesting only in your broadcast address

    thanks
     
  3. Bigbeef

    Bigbeef

    Joined:
    Apr 6, 2013
    Posts:
    31
    Ok. Not sure if this is what you need...


    My ipaddress for HOST machine is 192.168.1.7 <- IP of machine I'm trying to run as Host
    My ipaddress for CLIENT machine is 192.168.1.9

    So using an broadcast address calculator returned the same results for both:
    Network or Listen Address: 192.168.1.0
    Broadcast Address: 192.168.1.255


    The NetworkDiscovery issue happens at both my work test LAN at the studio and at home.

    I can use NetworkDiscovery component to easily connect two instances of the game running locally on 1 PC.

    But soon as I try to connect 2 game executions running on 2 different PCs on my LAN, the button to connect that pops up when listening fails to connect the games.

    On Host, using the NETWORKDISCOVERY component GUI, I press the (Initialize) button, then press (Start Broadcasting) button.

    Then on client, using the same NETWORKDISCOVERY component GUI, I press the (Initialize) button, then press the (Start Listening) button.

    On the client a new button almost instantly pops up and says :)ffff::192.168.1.7). It looks like it's working, because 192.168.1.7 is the host's IP address!

    But I press the button... nothing happens. Very strange.
     
  4. aabramychev

    aabramychev

    Unity Technologies

    Joined:
    Jul 17, 2012
    Posts:
    574
    Looks like you are doing something wrong :)
    I would say shrink your project remain only this problem. zip it and send me I will take a look :)
     
  5. Bigbeef

    Bigbeef

    Joined:
    Apr 6, 2013
    Posts:
    31
    I made a tiny test project, it's just 1 network ID quad and the networkmanager / networkmanagerHUD / networkdiscovery components on a game object, set up just like I did in my main project.

    http://www.filehosting.org/file/details/655031/bvStkQmk3IFtT0iR/NetDiscoveryTest.zip

    There's link to download the zipped project.

    If it matters, I'm trying to utilize networkdiscovery from PC to android device. Just adding that in there in case that's an issue that needs to be addressed. (using an Nvidia SHIELD tablet).

    Also, thanks for the quick response! I'll keep checking back to see if you find anything wrong.
     
  6. aabramychev

    aabramychev

    Unity Technologies

    Joined:
    Jul 17, 2012
    Posts:
    574
    @Bigbeef send me pm please, I just afraid that i can forget :(
     
  7. fruehstueck

    fruehstueck

    Joined:
    Dec 30, 2017
    Posts:
    1
    hi,
    any solution update to this problem?
    got the same here. would benefit : )
     
  8. Sha_ma

    Sha_ma

    Joined:
    Jun 14, 2019
    Posts:
    8
    Hi guys, I have the same problem. if anyone know what is the case here please hint me :)