Hi guys, I’ve been trying to learn multiplayer and networking with unity through the Multiplayer iPhone tutorial. Which I have been working on with windows, not the iPhone.
http://download.unity3d.com/support/resources/files/MultiplayerTutorial.pdf
There seems to be an issue with setting up the UDP connection, in this part specifically:
public void start_server() {
try
{
while(true)
{
System.Text.ASCIIEncoding encode = new System.Text.ASCIIEncoding();
byte[] sendData = encode.GetBytes(Network.player.ipAddress);
server.Send(sendData,sendData.Length,ip_broadcast,System.Convert.ToInt32(port));
Thread.Sleep(100);
}
} catch {}
}
This line is the one that throws the error:
byte[] sendData = encode.GetBytes(Network.player.ipAddress);
And the error says UnityEngine.Network:Internal_GetPlayer(). I got the MasterServer working fine, but my manager also wants UDP working as well. I’m wondering if it’s something to do with ports, but I’m not sure. I’ve looked up some docs for UDP but I am more familiar with TCP. Any advice or ideas would be greatly appreciated. Thanks!