Error in UDP connection for Multiplayer Tutorial

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.

There seems to be an issue with setting up the UDP connection, in this part specifically:

	public void start_server() {





	       System.Text.ASCIIEncoding encode = new System.Text.ASCIIEncoding();

	        byte[] sendData = encode.GetBytes(Network.player.ipAddress);          




	 } 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!

So, for this tutorial, don’t use Network.player.ipAddress. When the person starts the server, it catches the ipaddress in the variable ip.

 if(GUI.Button(new Rect(10,10,100,30),"Start Server"))


			youServer = true;

			Network.InitializeServer(32, listenPort);

			string ipaddress = Network.player.ipAddress.ToString();      

			ip = ipaddress;

The fix is this:

        byte[] sendData = encode.GetBytes(Network.player.ipAddress); 

        byte[] sendData = encode.GetBytes(ip); 

So, to all that are using this tutorial and using UDP, there’s the fix.

The above answer solved my question, but for some reason I can’t tumb it up.

Thank you very much