0

The code below is how we can host or join a game using unity networking system. As you see in the code below there is two input fields that normally take "localhost" and "7777".

public class CustomNetworkManager : NetworkManager {

    [SerializeField] InputField InputField_IP;
    [SerializeField] InputField InputField_Port;

    public void HostGame()
    {
        singleton.networkPort = InputField_Port.text;
        singleton.StartHost();
    } 

    public void JoinGame()
    {
        singleton.networkPort = InputField_Port.text;
        singleton.networkAddress = InputField_IP.text;
        singleton.StartClient();
    } 

}

But I want to create a game that a player can host a game then his IP an port will be shown (for example) in a UI text and he could send that IP and port to other players and they could join the game. I am still new to networking and can someone tell me please is that could be done and is there a way to join a host that is connected to internet but you are not on the same network? Note: I am talking about android devices.

Armin
  • 576
  • 6
  • 13
  • Unity's NetworkLobbyManager and CreateMatchRequest API are used for this. These are **not** [free](https://stackoverflow.com/questions/36091976/can-i-use-the-unity-networking-hlapi-without-paying-for-the-unity-multiplayer-se/36092168#36092168) to use. See [this](https://stackoverflow.com/questions/43543552/how-to-design-my-online-game-server-for-unity3d/43547277#43547277) if you want to know how to make yours from scratch. – Programmer Aug 15 '17 at 16:31

1 Answers1

0

https://www.assetstore.unity3d.com/en/#!/content/41836 You can use this asset and there's a tab named Manual Connection, which does the exact thing.

ZayedUpal
  • 1,603
  • 11
  • 12