Calling the Experts! Problems with Networking: Client/Server Architecture

[Edits and answers below]

TL;DR: I will explain my process of creating a multiplayer game with Client/Server Architecture with a scalable Mastar server and Dedicated Server Instantiation, it’s on progress

Hello everyone, the question is simple, however I’ve already researched like a slave and got nowhere satisfying. I need your help to define what is the best solution for my actual problem.


The Project

My project is a FPS Game (no surprises), but guess what, we would need physics calcullations for getting the projectiles to actually hit the players and things like that. I have already developed a simple demo for the game, and it works with uNet (or Unity Networking for 5.3+). The projectiles are part of a particle system with collision module, and they work. You see, life could be simpler, this could be my only need, but it isn’t. What I did to make it work was to use the HLAPI, extending NetworkManager and all this stuff.


What I need the project to be

I need that the multiplayer system works just like Rocket League for example. The player would choose to play online, then the master server puts him in a lobby with a bunch of other people, then allocates the nearest server and finally connects them all to it. Come on, Rocket League is a physics-based game (although it is made on Unreal, but it shouldn’t differ much from Unity on that part), I just wanted to know if that is too hard to make. What I understood of a client/server architecture is that there is a authoritative server that handles the players inputs and things like that, but in this case (Rocket League case) it (at least looks like) this is a dedicated server and it is instantiated only when needed. Also I would need a database server to store things like level, tier, ranking, etc.


What I actually have and understand of uNet

Well, as I said, I have a simple working demo using the HLAPI. The problem is, there is no dedicated server and I have absolutely no idea on how to do it. I really wouldn’t like to use other things like Photon or uLink (does that even exist yet? most of networking answers are old) not just because of the cost, their solutions don’t really fit. Not even uNet when it says I can only have 50 concurrent users and if I need to have more I have to pay tons of cash. I believe I can make an approach where I could spend less.


What I expect to have

  • Master Server (gets all connections, lists online players, matches players in lobbies)
  • Dedicated Servers (running physics simulations, or not if there is another approach)
  • A well implemented client/server interface (guess that is my part but I could use some tips)
  • Database Service (this is the easy part I guess, I just need some tips of services)

What I do have that could help

  • Well fundamented knowledge of Unity Engine (C# and unity features are not a problem)
  • Good knowledge of node.js (could that possibly help me to build a master server?)
  • Basic database knowledge

How can you help

  • Share your experience with networking (and how you solve your issues)
  • Give me advices about client/server architecture
  • Advise on how to create a master server or where I can learn to
  • Indicate good database services (I was looking at Amazon Services, as they are reliable and stable)
  • Give any more advice about everything I said, I’m really looking for help

I’ll be actively looking for answers and researching. Although I would appreciate some help, if nobody shows up or anything like that, I’ll post how I got to the results I needed. Thanks for the support.


Edit #0 - Day 1

I’ve been through researching and found out that Unity’s uNet uses a relay server to connect the clients and the host online (which is the address that appears on NetworkManagerHUD if you enable MatchMaking), This thread comments exactly about bypassing Unity’s relay server with a direct connection to the hosted server, but it would need a NAT Punch-Through. There is a plugin on the asset store that does the job, But I want to consider doing it myself (if I can do it, I’m also considering to share it for free, or with an open-source structure).

Next I found this thread that compares Peer-to-Peer with Client/Server (using a host) and with Client/Server using Dedicated Server. Most of the things I already commented here, but is a good reference to look at. However, he mentions running Unity standalone player in a headless mode, so it can act as a dedicated server. That part catched my interest. I figure this is something like Nelson Sexton used to build Unturned’s Multplayer System, he has this headless standalone running and people joining servers, however he did not add this NAT Punch-through as people have to port forward in order to sucessfully connect.

After that, I got into this repository that has some interesting references using uNet’s HLAPI to build both server and client. Although it is very simplistic, it shows a good implementation of the NetworkServer class. Using this approach, the idea of the headless standalone server gets more and more attractive.

This post has interesting details about some more networking code. Things like ClientCallback and ServerCallback can optimize the functions by making them execute only on the appropriate instance of the game, now that’s what I call a valuable information.

I found this treasure chest containing sample projects and a lot of links to other relevant places. First of all, there is this Master Server Sample that contains some good-looking server implementation, but it wouldn’t work online, only in lan (that sucks really bad). They also have this moba sample project that features nothing interesting at the point of Client/Server study so I think I’m losing the point here.

The very creator of the NAT Traversal made a post about NAT Punch-Through with a public repository. This could probably help something. There is some angry people on the forums commenting about the fact that uNet seems abandoned, which after reading all of their post, seems to be somewhat true. This same person made an unofficial workflow tutorial on how to create a matchmaking process using HLAPI, and that seems to be the best I found today. I’ll check out some of his material, and I’m now considering to use Photon, thanks to all research.

What I Learned now:

  • There could be a possibility of running a dedicated server instance of the game by running Unity on this headless standalone mode
  • In this case, in order to the players successfully connect to the server, it would require a NAT Punch-Through server-side
  • It is possible to setup server functionalities by using the NetworkServer class
  • uNet has a “low activity and attention” from the devs
  • There is a public repository for NAT Punch-Through
  • There is an unofficial workflow post following HLAPI and Match Making
  • There is a light in the end of the tunnel (if everything goes wrong, I’ll switch to Photon)

Edit #1 - Days 2, 3 and 4

Guess what, I’m implementing the game with Photon Unity Networking. At first sight, as I need dedicated servers, it won’t be any easier, the only difference is that they provide a Server SDK where I can setup my own Master Server with my scalable dedicated server hosting functionality. Hold your horses, I’m still porting the stuff I had to Photon (no it should take only one day, I’m taking three because I’m reworking everything from the beginning, and because yesterday I did nothing), but soon I’ll work on the server side too. They work very similar to the Unity HLAPI, using the Client/Server with a Host player (if you use Photon Cloud).

Photon Advantages Over Unity Networking

  • Server SDK for building my own Master Server
  • Somewhat better documentation and support

Unity Networking Advantadges Over Photon

  • Built-in
  • Much powerful integration

Edit #2 - Days 5~10

I decided to abandon photon, for a lot of reasons. Personally, I think my intentios will be clearer by using Unet over Photon, even with dedicated servers. There is a lot of research already here, so you just need to point everything out tracking the pros and cons of each. For me, the built-in support of Unet is just great, even though there are no much documentation, I’m investing my time and research on it instead of Photon.

Don’t get me wrong, Photon is an awesome asset, they have a lot of support. It’s just that, to my game, it won’t work as I would like. You see, they have the Photon Server solutions, which would be the perfect mix, but I’d rather choose something simpler that gives me more control over things. It means I’m building my own server stuff to integrate with Unet. Is that a smart decision? Probably not, but I’m willing to help more than just myself.

After my research, I could see that a lot of people would like to implement this sort of multiplayer interface, but no one ever reports success or don’t report how they achieved it. I have plans to make it available if I ever make it through. The more the community helps itself, more its projects will be better and better.

Last but not least, I have some useful links to help on the journey, that I got from talking to some game development teachers:

it was a couple years ago since i started my last network game and unity has changed there network stuff since then. seems it does a lot more stuff now. but there are some principles that will always be the same.
the only purpose of unity’s master server is to preform NAT punch through and connect game copies so that they can comunicate to each other. it works great. and NAT punchthough is not something you would want to try coding yourself unless you feel like endless nights of banging your head against the keyboard. the master server source code is free and downloadable from unity to run wherever you want.

I never bothered adjusting unity’s master servers source code. its simple and works great. for anything extra that it doesnt do, i write it seperatly with my node.js server. Node is wonderfull and super easy to write for many things. It can send updates or files and let game copys update stats and additional stuff like that but I still let unity’s master server do connection and punchthough.
i personally just run my servers at home. its realitivly simple to set up a static IP and assign a dedicated port on any router. you could rent space for a server elsewhere too.

what is actually communicating the game-play physics are the game copys. i would think if you wanted a particular ongoing level that players are joining, the easiest would be written with unity itself that is logged into your master server.

when designing the architecture of your game, you must consider the principal that any modern possessor can calculate far more than what can be sent through a bandwidth. so network communication is on a “need to know basis”. any calculations of physics comming back through a bandwidth is going to be not as accurate as what would have been calculated locally on the users machine.