Creating an MMO in Unity is HARD but it doesn’t have to be!
So you want to create an MMO with Unity but everyone is telling you not to do it. I don’t blame them! Creating a massive multiplayer online game (MMO) is a goal that’s always been out of reach.
We’ve all heard the stories, right? An indie game developer spends countless hours on their dream project only for it to fall apart. And there are plenty of articles on the web outlining why it’s so hard to develop an MMO.
But let’s say you have a great idea that only works as an online game with many players. Can it really be that hard?
Well, for one thing, MMOs are literally the most complex type of game you can create. You’ll need to consider many things at each stage of the game development cycle.
Furthermore, you’ll need to travel into territory that many developers actively avoid: The Internet. And once you’re there, you’ll have to navigate a world of technical complications that’re doing everything they can to stop you in your tracks.
But don’t lose hope! This problem has been around for years and many bright developers have been working to solve it.
Let’s explore the technical challenges that make it so hard to make an MMO with Unity. Then let’s take a look at a specific SDK that’ll help you overcome them. By the time you’re done reading this article, you’ll be on the right path to making your very own massive multiplayer online game!
The first thing you need to consider when creating an MMO with Unity is your infrastructure. This is where your game will live when its released. Try to answer the following questions.
- Who will host your game servers?
- What type of server architecture will you use?
- Where will you store your data?
- How will you monitor and support your infrastructure?
And those just scratch the surface. Each decision you make will lead to whole new set of questions that need to be answered. And each one can have major implications for your code.
For example, what type of server architecture should you use? To answer this, decide how large your game world will be and how many players you expect it to host.
World of Warcraft, a popular MMORPG created by Blizzard Entertainment, has a massive world that hosts millions of players across it’s 200+ realms. That many players require a distributed server architecture, where hundreds of servers are working together to provide a single, seamless experience.
But maybe your game doesn’t need level of scale. Smaller game worlds that expect to see less players can easily live on a single server without any issues.
In either case, the infrastructure you create will result it’s own unique code base that’s designed to meet it’s specific needs.
Once you stand up your infrastructure you’ll be ready to write some code. Again, MMOs are the most complicated type of game you can make, and a lot of that complexity lives in the network code.
To give you some perspective, think of some basic logic you’ve written for a single player game. Let’s say player movement, for example.
That logic only need to be executed one time in a single player game. It effectively amounts to one unit of work.Your logic will have to synchronize data across every client. And, as a result, you can end up with an exponential problem where codes that’s responsible for one unit of work is now responsible for N units of work, where N is the number of active players.
Of course this isn’t always the case, but it’s definitely something that you need to keep in mind when adding features. As well as all of the other complicated things related to network code, like making connections, dealing with lag, and handling disconnects.
Writing network code from scratch is no trivial task. And it’ll likely eat up a lot of your resources during each stage of development.
So, as it turns out, it’s really hard to create an MMO. It’s a complicated endeavor with lots of moving parts and plenty of opportunities for failure. So should you just cut your losses and give up now?
It’s 2018 and there are very few programming challenges that can’t be overcome with Google and a well-written SDK. There are plenty of bright developers who’ve been working hard to ease the technical challenges that come with making your own MMO.
As a result, there are tools, SDKs, and game engines that were specifically designed to tackle this daunting problem. And while none of them are perfect, there are definitely a handful that’ll help you get the job done.
Let’s take a look at a couple of solutions that are readily available to you.
Unity’s Multiplayer High Level API
In 2015 Unity released the Multiplayer High Level API (HLAPI) which gives developers the ability to write networking code using MonoBehaviours. This is a huge advantage for Unity developers as it makes it extremely easy to add multiplayer capabilities to their existing single player Unity games.
On top of that, Unity also has a set of internet service that integrate directly with the HLAPI. These services include logging, analytics, and even matchmaking base on the popular ELO rating system.
The HLAPI is a great option if you’re new to writing networking code. Again, it’s built on top of Unity’s existing MonoBehaviour ecosystem so it has a relativity shallow learning curve. And the internet services provide a solid infrastructure that’s easy to deploy to. The problem with the HLAPI is that it uses a peer-to-peer (P2P) architecture.
Games that utilize a p2p architecture rely on one of the connect players to become the host. In other words, one of the player’s client’s is responsible for managing all of the server-side logic. Ignoring the security risks behind that, a player host must bear the burden of synchronizing all of the other player’s clients. While this works fine for a relatively small 16-32 player match, this is a terrible option for an MMO that can have thousands upon thousands of players.
As nice as Unity’s HLAPI is in theory, it’s just not the right answer for developing your MMO.
So Unity’s multiplayer HLAPI isn’t an option. Luckily for us, there are many third-party solutions out there that attempt to overcome the difficulties associated with creating an MMO, however few of them do it quite as well as SpatialOS.
SpacialOS is a game development platform that comes stock with all of the infrastructure, code, and game engine integrations needed to create an MMO with Unity. It’s cloud-based services are built on a distributed system architecture, hosted on Google Cloud Platform, that’s designed to scale with hundreds of players, if not thousands, in mind.
SpatialOS also includes a well documented SDK that’s designed around the well-known Entity-Component-System pattern. It integrates directly with Unity and has some great tools that take a lot of the pain out of developing and deploying an MMO.
And once your game is deployed and released, you’ll find that SpatialOS handles most, if not all, of the complex heavily lifting needed to meet the demands of your growing player base. As a result, you can focus on creating content for your players instead of worrying about your keeping your game online.
Developing, deploying, and maintaining your very own MMO is an enormous undertaking, but it’s becoming easier and easier as the years go by.
Game engines like Unity are taking more and more measures to add multiplayer functionality to their set of features. And third-party platforms like SpatialOS are springing up rapidly with specialized solutions for this very specific problem. And they’re doing so with great success.
Once upon a time, creating even the simplest game was an impossible goal left best to large game studios. But now thousands of indie developers release their own games every year. It’s only a matter of time before we see a new movement of indie MMOs on Steam.
Don’t get left in the dust. If you dream of creating an MMO, then now is the time to get started. Harness the tools that are available to you and then maybe your MMO will be among the first to make it big.
Get started with SpatialOS today! Check out their technical breakdown that covers how it works and how it can help you meet your goals.