Search Unity

Multiplayer not on LAN

Discussion in 'Multiplayer' started by rotm987, Dec 26, 2018.

  1. rotm987

    rotm987

    Joined:
    Jul 21, 2018
    Posts:
    2
    Hey,
    i'm trying to make a multiplayer connection between few computers
    the problem is that it works only on LAN

    i've seen many games for example rust and the forest
    that are doing it, just create the server on client
    those servers are hosted on the users and not on server

    can someone explain me how to do it?
     
  2. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    11,847
    There are several options, which generally break down to:
    1) Have any player wishing to host a game manually enable port forwarding on their own router
    2) Use a technique referred to as NAT punch-through
    3) Host a relay server, so the game server actually connects as a client, and all game traffic passes through your own server
    4) Use a 3rd party service which all clients and the game server connect to (Photon, deprecated Unity Multiplayer Service, etc)
     
  3. rotm987

    rotm987

    Joined:
    Jul 21, 2018
    Posts:
    2
    thanks for the reply

    do you know maybe what option those games that I mentioned used?

    all i want is it to host server on client, without to open any port on their own or any weird this
    can't afford to buy servers cause they are so expensive, the perfect option is to host on one of the clients
     
  4. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    11,847
    Options 2, 3, and 4. They each have their pros and cons.

    Well that actually is a more complicated issue than you may realize, due to the ubiquitous nature of consumer grade routers which prevent computers behind the router from being accessible to clients from the internet. You should do some research on what NAT is and what non-routable IP addresses are so you understand what you're asking for.

    You might want to look at using Photon first, because other than your users manually opening ports on their router (option 1) you would need to host some kind of server for options 2 and 3. Option 4, such as Photon's service, is basically outsourcing the server portion.