Can I use the Unity networking HLAPI without paying for the Unity Multiplayer service?

jenkins picture jenkins · Mar 18, 2016 · Viewed 24.7k times · Source

I saw Unity's Multiplayer service page, and I'm completely confused:

Can I use Unity's high-level networking API (NetworkManager / NetworkManagerHUD) in a published game without paying for Unity Matchmaker and the Relay servers (whatever those are)?

I have my own cloud-based VM that I want to run a dedicated server on. My project is just a small game I would play with my friends (nothing commercial or large-scale). I want to run a published copy of that game in dedicated server mode on my VM, and have my friends run their published client copy and connect to the server via the NetworkManager.

Can I do that for free? I don't mind if my friends have to manually enter the server's IP and port in their game copy using the NetworkManagerHUD. Would them doing so count as a "CCU" (limit of 20 for Unity Personal)? Would that use Unity Matchmaker bandwidth ($0.49 / GB, not even available for Unity Personal)?

Any clarification would be appreciated! :)

Answer

Programmer picture Programmer · Mar 18, 2016

You can use Unity HLAPI without paying. Just don't use the Unity match making API, then you won't need to pay for anything.

You can get another player to directly connect to another player that is not on the same local network but you need to perform port forwarding on each computer. Players can perform port forwarding through their router settings but you don't want your player to go through this. You can do port-forwarding from C# script but it is complicated if you don't know anything about networking. There are many C# libraries that can do this so that you have to re-invent a wheel.

Once you get port forwarding working, you can then use the Unity standard API to directly connect to another player in another network.

If you want to take this further, you can have a script that sends the IP Address and the port number of the players to your server so that players can connect to each other automatically without having to manually type in the IP Address and the Port number of each computer.

EDIT :

Unity match making API = All classes inside UnityEngine.Networking.Match, such as NetworkMatch

Unity standard API = NetworkServer and NetworkClient

You should NOT use NetworkManager because most of its function depends on Unity match making API.

To create a network game that is free from Unity match making API, you just need the NetworkServer and the NetworkClient class.

To create Server:

NetworkServer.Listen

It has overloaded methods such as

public static bool Listen(string ipAddress, int serverPort);
public static bool Listen(int serverPort);

To create Client(Connect To Server):

NetworkClient.Connect
public void Connect(string serverIp, int serverPort);

You will lose functions such as creating and joining games if you don't want to use Unity match making API. You can use the NetworkServer and the NetworkClient I mentioned above to create a complete network game. Just create a server, connect to it and start sending and receiving information. It is worth it because when Unity's server goes down or begins to get slow your game would still be working unlike others.

NOTE: Unity is working on Application that lets you host your own game. This is NOT out yet but when they release it, you will be able to host your own game without Unity's Server by running that Application on your server. Right now, they want you to pay to use their some of their network codes but real coders won't have to do this.