Hi, I’m implementing multiplayer in my game using built-in Network and MasterServer from Unity3D.
I started a system that polls server and automatically connect if found. If none are found after a specific period of time (usually 5 seconds), then it automatically acts as a server.
It almost work but it’s kinda weird: it polls correctly for server and can become a server, no problem so far. When I fire up another instance of the game on another computer, it finds the server, its IP is correct but it doesn’t seem to really connect correctly to it.
To be a bit more technical, when using Network.Connect (hostData)[/B], it returns NetworkConnectionError.NoError which means it is connected, right?
When I check the Network.peerStatus it says NetworkPeerType.Disconnected which doesn’t make sense to me since Network.Connect didn’t return any error. And of course, events like OnPlayerConnected, OnPlayerDisconnected and OnConnectedToServer don’t fire.
Does anybody have an explanation/pointers on why Network.Connect() returns NetworkConnectionError.NoError when in reality it isn’t connected. I tried with and without encryption, NAT and ‘Run in Background’ (Project Setting → Player settings) but it doesn’t change anything.
Let me know if you need additional details.
Note: I sometimes get a message about NAT even if NAT is not selected only when encryption is enabled.
Note 2: Max connections is set to 30 when creating the server (should be more than enough to handle a single connection).
Note 3: I’m running Unity3D 3.4.2, one instance on OSX Lion, the other on Windows 7 and both computers are on the same network._