Search Unity

P2P without UNet?

Discussion in 'UNet' started by GitWither, Oct 4, 2019.

  1. GitWither

    GitWither

    Joined:
    Jul 16, 2018
    Posts:
    2
    So now that UNet is getting deprecated, what will be the best way to create a P2P game similar to what UNet offered (simple setup, high-level API)? So far, everything I've seen announced is solutions for large-scale server-based multiplayer projects.
     
  2. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    11,847
    The thing with P2P on the Internet is everyone is behind NAT routers, so you need a service or your own server which handles connecting clients together since none can actually act as a server from a networking perspective. That isn't functionality that typically is bundled into 3rd party network API's from what I've seen. Unet handled this via the Unity Multiplayer Service, which was a pay for what you use service technically outside of the Unet API itself.

    The one that sticks out in my head is @TwoTen 's MLAPI Relay in conjunction with his MLAPI. I haven't used it, but the creator is on the forums all the time and knows his stuff.

    https://forum.unity.com/threads/standalone-unet-relay-mlapi-relay.535970/
    https://forum.unity.com/threads/mlapi-hlapi-replacement.511277/

    There's also the cloud based flavors of Photon to consider if you don't want to manage your own server for this.
     
  3. TwoTen

    TwoTen

    Joined:
    May 25, 2016
    Posts:
    1,168
    Hm yea. MLAPI is a high level library similar to the HLAPI. It offers nothing in terms of allowing P2P. It's a modular library that allows you to pick and choose what you want. Instead of boxing you, it's just there to help you.


    Enough of that plug, my other two projects are MLAPI.Relay and MLAPI.Puncher. They both work with the MLAPI but can also be used without it if the MLAPI is not your cup of tea. MLAPI.Puncher is a hole punching library that will trick routers into talking to each other, creating a temporary NAT association. It works for many home routers, but can fail on enterprise grade routers and will almost always fail on cellular. It's cheap to host and there is even a puncher server I host that you can use for testing.

    There is also the relay, which relays all the traffic between peers. This introduces latency but will guarantee that the connection can be established in all circumstances. So one common way to approach it is to try to Punch with a puncher, and only if that fails fall back to relaying the traffic since it's much more expensive (but still much cheaper than running dedicated servers) than the puncher.


    Remember that this still has all the hassle of managing servers etc which you probably wanted to avoid in the first place. There is no magic sadly, it's just that relaying and hole punching is much cheaper, but it's still not free. (even though hole punching is ridiculously cheap to host). If you really don't want to handle this, cloud solutions is probably worth looking into. But it does have a price tag.
     
    Last edited: Oct 5, 2019
    Joe-Censored likes this.
  4. Laylson_Fernandes

    Laylson_Fernandes

    Joined:
    Sep 27, 2019
    Posts:
    2
    I am looking for alternatives to create a local area connection, to create a virtual reality system. So I am looking for ways to create a server or local connection, without going over the internet, just for communication between mobile and computer.

    I am currently studying the use of Node.js, but with this issue of Unet becoming absolute, the question arose. Can I still implement this kind of connection? will Unet discontinuity get in the way of something? There are more efficient solutions for making this communication.

    I am a student in digital game development, and I am researching for a college project.