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.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…