Can I use the Unity networking HLAPI without paying for the Unity Multiplayer service?
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.
jenkins
Updated on July 09, 2022Comments
-
jenkins almost 2 years
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! :)
-
jenkins about 8 yearsBy "Unity match making API", I assume you mean, for example,
NetworkManager.StartMatchmaker()
? This means that what I want to do is essentially use Unity's NetworkManager with my own Matchmaking system. Is that what your answer is describing? Also, what do you mean by "Unity standard API"? Were you referring to the UNet HLAPI? -
Programmer about 8 yearsI made an edit to the question. Everything I posted is about UNet HLAPI.
-
jenkins about 8 yearsCan't upvote your answer (not enough rep), but thanks a lot for the very detailed explanation!
-
LumbusterTick almost 8 yearsIs NetworkManager part of Match Making API? Because we can use that to connect to ip's wihout using matchmaker that comes with it.
-
Programmer almost 8 years@LumbusterTick Yes. It has
StartMatchMaker
function and I assume thatMatchMaker
is implemented under the hood. Yes, you can connect with another IP but I said that so that he won't be tempted to use theMatchMaker
API in it because it's not free. Until Unity releases the server code,NetworkManager
should not be used by those who wish to use their own server. -
Muhammad Faizan Khan over 7 yearsI don't have any dedicated server. I have just a player which i provide it to my friend but he is unable to connect it using ip. I used default HUD of network manager. stackoverflow.com/questions/41805295/…
-
Muhammad Faizan Khan over 7 years@Programmer you said don't use NetworkManager if you have own server so what to use, any ref/alternate script?