Have you ever wanted a Unity-official solution for multiplayer networking in Unity? Or – do you perhaps just want an alternative to using multiplayer frameworks like Photon and Mirror?
Allow me to introduce Unity MLAPI (or Unity Multiplayer Networking as it’s now called) – the new kid on the block who is ready to help you build your own multiplayer games. While MLAPI is still in active development by Unity Technologies, it comes with huge implications for future Unity game projects. As such, whether you’re looking to explore additional multiplayer game methods or want to expand your skills, mastering Unity MLAPI opens up a world of opportunities.
What is MLAPI?
The acronym, “MLAPI,” stands for “Mid-Level Application Programming Interface” (Mid Level API). In networking, APIs are categorized as being either mid-level, high-level, or low-level. A low-level API deals with things like serializing data, communicating with a network transport, and managing connections. It deals with the nitty-gritty of programming and networking. A high-level API sits on top of the low-level API and makes the complicated processes cleaner and easier to use. It is much easier to program with a high-level API than with a low-level API. That being said, there is a performance cost to using a high-level API. If you want a memory-efficient networked application, using a high-level API isn’t always the best choice.
Enter, Unity MLAPI. Being a mid-level API means it has access to the basic processes of a low-level API while feeling like a high-level API. MLAPI is designed to be the best of both worlds. It gives you access to the central network processes and maintains a level of abstraction for ease of use.
What can you do with MLAPI?
The true answer is “the sky is the limit.” Of course, there are a couple of things that MLAPI shines at. The biggest is security and connection approval. MLAPI will authenticate on a per-connection basis. This means that you can write your own custom logic and specifications for incoming connections. Having a system like this not only gives you a lot of options for connection authentication but also increases security. Any connection that doesn’t meet your requirements (like providing the right password) is simply denied. This makes MLAPI a serious choice for developers that want a level of security and customization.
However, because MLAPI deals with some lower-level interactions, it is not as easy to learn compared to a normal high-level API. Knowing how to use MLAPI requires a decent amount of experience with C#. While the learning curve is steeper, projects made in MLAPI are easier to scale. Plus, since it is a Unity Official package, it is far less expensive to run than some third-party high-level APIs. All these traits combined make MLAPI an attractive choice for independent game developers.
Where can I get started using MLAPI?
The first step is to download and import MLAPI into Unity from the MLAPI Github: https://github.com/Unity-Technologies/com.unity.multiplayer.mlapi. The documentation for MLAPI can be found here: https://docs-multiplayer.unity3d.com/netcode/0.1.0/getting-started/about/index.html. You can also have a look at Unity’s announcement after acquiring MLAPI: https://blog.unity.com/games/accelerating-unitys-new-gameobjects-multiplayer-networking-framework. This has some information about what the developers are hoping to accomplish with this package. While the documentation covers the basics, it is good to search around for other content that covers MLAPI in more depth. An excellent tutorial series is on Dapper Dino’s youtube channel:
Links
Tutorials
- How To Make A Game With Unity Multiplayer Netcode | Project Setup by Dilmer Valecillos
- MLAPI — Unity Networking of Future Past by Gamefromscratch
- Setting up a multiplayer game in Unity by SRCoder
- How To Make A Multiplayer Game In Unity 2021.1
- How to set up a custom connection address by SRCoder
- Watch this before using MLAPI by Epitome
- MLAPI Multiplayer by Mr Benji
- Unity Multiplayer Tutorial: Spawn and Equip Items Using Unitys New Multiplayer System (MLAPI) by Slaymuel
With these tools, I hope you can quickly get started creating multiplayer games in the Unity engine! Unity MLAPI is a new frontier for game development that is sure to present all developers with new opportunities. We’re expecting new features and new content related to the Unity Multiplayer Networking system as well, so keep checking back!
BUILD GAMES
FINAL DAYS: Unlock 250+ coding courses, guided learning paths, help from expert mentors, and more.