Kilnir – Networking (Why I chose to make my own)

The problem began with figuring out which tool to use to handle the networking for my game. Now, I knew that I will have to build an UI on top of any of them and pretty much do my custom integration regardless so what I was interested in was performance and easbility of modding plus an approachable learning curve. In my research I think I’ve come across most if not all the big names, UnityNet, Photon, SpatialOS, uMMO and many others. Besides these the Unity asset store has a lot more scripts and projects asserting they do networking to offer but I didn’t bother trying any of those.

UnityNet

First solution I tried was Unity’s own stuff. It was already integrated and provided some basic UI pre-made which made it very easy to setup and test. And as soon as I did I ran into problems. Even on localhost, host and client on the same PC, the client lagged. Sure, there might’ve been something wrong with my configuration but none of Unity’s tools complained and I still had over a full second of lag between the client and the server.
Being in a very early stage of development I conceded on the lag and moved on to trying to solve the next problem, dedicated server. Something that could still be self-hosted easily by the players but not a peer-network setup. I must’ve spent weeks trying to figure this out to no avail. Short of making a different unity app/project that would act as a server I could not figure out any solutions.
The cherry on top, or final nail in the coffin to be more accurate, was pricing. For something that sort of/kind of works out of the box but with huge lag even on a local connection Unity sure charges a lot. Based on their calculator for 50 concurrent players it’d run me around 200USD/month. I plan on having a lot more concurrent users than that and this still doesn’t allow for self host. I don’t want to make a game that goes down because Unity decides to scrap their cloud networking service. Not that I’m confident that the game will turn out that well, I just don’t want this to be a possible scenario to begin with regardless of how the game turns out.

Photon

After deciding thet UnityNet isn’t going to cut it I started looking into Photon. It still had all of the problems of UnityNet except that it was half the price. To be completely honest, I’ve only setup a simple test using their free tier and that worked great but it still locked my project into being dependent on their lifeline. If I were to chose between Photon and Unity to tie my game’s life to I’d definetly choose Unity all day every day regardless of price difference.

SpatialOS

This is the new kid on the block regarding Unity networking and it shows. It’s great, once you figure out how to actually use it. They have some examples but none of them JustWorkedTM and I had to spend hours setting and configuring things only to get it to work. To be honest, once it does work, it works great. After I figured out how to set the server FPS limiter to more than 30 (no idea why it’s set to 30 by default) the lag was minimal and experience was very good in their “Pirates” demo. For testing I didn’t have to pay anything and they don’t have a proper pricing page yet but based on the tech, it’s definetly going to be expensive (or at least it should). The partners they have already developing games on their tech looks impressive but is also intimidating, at least to me. Besides, I could barely find any walkthrough styled tutorials on it and the documentation can’t decide what it documents. I have more than once come across a refference cycle where the next step was the first step in a new page till you get back where you started from.
I enjoyed playing with it. It AlmostJustWorksTM, the performance is great and the worker abstractization layer is impressive. Main problem, and what drove me away in the end, is the very steep learning curve.

uMMO

This looked like the most promising solution but with a 70EUR upfront non-refundable price tag I didn’t feel comfortable purchasing that lottery ticket. The reviews seem encouraging but there’s only 23 of them (this seems to be a recurrent issue on Unity’s asset store). Whilst going through the docs and such I realised that I can develop this myself given enough time and dedication. Even more so, I started this project as a learning experience so this made a lot of sense. In the end I decided that rather than paying the 70EUR I would instead learn to do it myself and figure out how it all works.

Next time

In the next post I’ll go over the solution I’ve ended up creating on my own using C# and Sockets, share some code(?) and explain how I’ve thought the entire thing out.