Search Unity

Looking for a starting point with online multiplayer

Discussion in 'Multiplayer' started by Siltuz, Jul 21, 2017.

  1. Siltuz

    Siltuz

    Joined:
    Apr 6, 2017
    Posts:
    4
    Hi all!
    I have had a look through and found a lot of good information on using unet to make a multiplayer game, and had great success in doing so in LAN and Local, but I am struggling to get this to work with users on different networks that are part of the same team as I am. I am not very adept at networking, only just starting to learn it to be honest, so I may be missing something simple, but is there a good starting place to begin looking at using unet to do peer to peer or some form of server based networking? I did see on someone else's project on youtube they were able to use the NetworkManagerHUD and Unity Multiplayer services together to achieve this, but my attempts at replicating it have failed I am afraid.

    Thanks for any support you can give on this matter.
     
  2. xVergilx

    xVergilx

    Joined:
    Dec 22, 2014
    Posts:
    3,296
    Well, to be honest if you want remote access to your server you would need an external IP. With that in mind, you would also need a proper access to the ports of the device you're connecting on to.

    As for a starting point - you can either go with Unet LLAPI (highly suggest it over HLAPI, manuals a bit lacking, but if you're good at programming you'll deal with that easily), Photon (well documented and supported), or Forge (also well documented and supported). You can always run something like a Master Server (There's an awesome and free asset called Master Server Framework, documented), or NAT Punchthrough plugin, or Relay Server to deal with the NAT problem.

    TL;DR: Unet LLAPI (free), Photon($), Forge($), MSF(free), NAT Punchthrough($), Relay Server($). These are the options.
    You would want something like those to transform your local game into a real multiplayer one.
     
  3. Siltuz

    Siltuz

    Joined:
    Apr 6, 2017
    Posts:
    4
    First of all, thanks for the response. A few quick questions though if I may?

    I should clarify that when I said some sort of server based networking, I meant through the unity multiplayer service, which if I have understood it correctly offers some sort of functionality for small server based testing? Mainly I am interested in peer to peer type connections but having a limited server to help testing sounded a good idea. With this in mind, is the LLAPI still what should be used, or can HLAPI be used instead? I am not great at programming, but I just about get by, I am actually more of the 3d modelling sort of guy though.

    MSF looks like it is quite good, I will definitely have to explore it, I am mainly looking into the free solutions for now as this game is more of a hobby than anything. The game is still in its infancy so there is not much to convert, I did a lot of testing of mechanics etc individually now I am trying to build the multiplayer aspect nice and early before implementing all the hopeful features.
     
  4. xVergilx

    xVergilx

    Joined:
    Dec 22, 2014
    Posts:
    3,296
    You can use Unity's multiplayer services, they're fine, as long as you're satisfied with the price. It doesn't offer any servers afaik, except for Relay. Which is kinda the only way to get around NAT with standard peer-to-peer.

    I suggest going with LLAPI, because HLAPI maybe easy to pick up (which I doubt it is, because manuals are horribly outdated), but LLAPI is much more flexible, and you'll get more control on what you're doing, or what's going on. ... And also it just works, where's HLAPI is just a mess without support ATM.
     
  5. Siltuz

    Siltuz

    Joined:
    Apr 6, 2017
    Posts:
    4
    I would mainly be using Unity's Relay server during the development, and I believe there is 20CCU free which should be fine, it just allows me to not worry about messing around with my internet settings so much (Hopefully).

    Besides the current documentation for LLAPI, any suggestions on a good place to start looking into it? I have found a few tutorials that I will look at to try get an understanding as to how it works, but if you have any recommendations for specific ones then I would love to take a look.

    Thanks again for the help!

    EDIT: Also any help on figuring how to connect to the relay server would be great too...
     
    Last edited: Jul 21, 2017
  6. thegreatzebadiah

    thegreatzebadiah

    Joined:
    Nov 22, 2012
    Posts:
    836
    @Siltuz If you go with my NAT Traversal plugin can you avoid the costs of the relays most of the time, and you won't have to deal with fiddling with router settings or anything. Plus with NAT Traversal you will get a direct connection most of the time which is going to be way faster than going through relays. Also it can automatically fall back to relay connections when needed so you don't even have to worry about figuring out how to write that code. Just call StartHostAll() on the host and StartClientAll() on the client and you are good to go. Also it's fully compatible with the HLAPI or LLAPI so you can use whichever you prefer (or a little bit of both).
     
  7. Siltuz

    Siltuz

    Joined:
    Apr 6, 2017
    Posts:
    4
    Thanks for the suggestion, I had a quick look at the plugin and it does seem pretty up my street, although it is something which I would be looking at later down the line due to the cost and the nature of my project (It is never something I will look to make money from really, just a bit of fun with friends, so until it is closer to completion I am avoiding sinking money into to.) As a note, is it easy to implement nat traversal at the end of a project or should I do anything within my project now to prepare for when it is needed?
     
  8. thegreatzebadiah

    thegreatzebadiah

    Joined:
    Nov 22, 2012
    Posts:
    836
    @Siltuz it's super easy to implement at any stage, especially if you're using UNet. It should just be a matter of changing two lines of code.