Im using UNET to make a wifi multiplayer game. I can connect two PCs just fine, however not two android devices, and not pc to android… the weird thing is that the match will show (using NetworkDiscovery) however it cannot connect (can only connect on pc to pc).
i believe the issue is as below: the serverIp variable is being set as “localhost” not the ip of the device.
public void Initialize(NetworkBroadcastResult value) {
string dataString = BytesToString (value.broadcastData);
var items = dataString.Split(':');
if (items.Length == 3 && items [0] == "NetworkManager") {
if (NetworkManager.singleton != null && NetworkManager.singleton.client == null) {
serverIp = items [1];
serverPort = Convert.ToInt32 (items [2]);
//NetworkManager.singleton.networkAddress = items [1];
NetworkManager.singleton.serverBindToIP = true;
NetworkManager.singleton.serverBindAddress = Network.player.ipAddress;
//NetworkManager.singleton.networkPort = Convert.ToInt32 (items [2]);
}
}
GetComponent<Button> ().onClick.AddListener (() => Connect());
}
//when the ui button is clicked..
//the serverIp shows as localhost rather than the ip of the device. i believe this is the issue..
public void Connect() {
NetworkManager.singleton.networkAddress = serverIp;
NetworkManager.singleton.networkPort = serverPort;
NetworkManager.singleton.StartClient ();
}