Search Unity

[SOLVED] Multiplayer debugging question: host and client work on same PC, not in actual LAN

Discussion in 'Multiplayer' started by woland, Jun 14, 2017.

  1. woland

    woland

    Joined:
    Jun 14, 2017
    Posts:
    2
    Hi,

    I'd like to ask this question to clear some things up. So far in tutorials and guides I've seen that multiplayer logic should/can be tested by building the project and launching the .exe and starting the game by hosting it and then joining to that game as a client either from the editor session or from another instance of the build. Ok, that has worked very well and I've implemented the multiplayer logic which has worked correctly with that setup.

    Now I've moved on to the next phase of testing and running the game for two different computers in LAN. The players connect and communicate but now not any object with a network identity is visible in the client who joins the game. Also getting some very strange behavior that hasn't happened as I've tested the game with both players on the same computer, for example in ClientRPC call I get an error for an object which shouldn't even be in anyway related to that that particular call.

    Simple example: In the scene there are two statue objects, which then the respective players control in a certain way. The objects have local player authority checked. The first problem before everything else that the statues are not visible in the client in LAN, but everything works ok when running the multiplayer clients locally.

    SO what I want to ask is that is there something architecturally or logically different when running the two clients from the same computer (i.e. localhost) and running the clients on separate computers? I've tried to find an answer for this for a couple of days and all I've managed to find is that it shouldn't act differently if I'm running the instances from the same computer.
     
    Last edited: Jun 14, 2017
  2. FMark92

    FMark92

    Joined:
    May 18, 2017
    Posts:
    1,243
    Set different ports for
    server -> client
    and
    client -> server
    communication.
    Also use local loopback IP (127.0.0.0).
     
  3. woland

    woland

    Joined:
    Jun 14, 2017
    Posts:
    2
    Thanks for the reply. I'm using the NetworkManager-component provided by Unity though so it seems that the port needs to be the same so that the Client knows where to join.

    But after all the struggle I happened to reboot Unity on the other laptop and then tried again the project and now client works as it should. Not the first time Unity editor sessions has just gone haywire and confused with itself, so I'm ashamed of myself not trying just turning it off and on again.