Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
1
Question by lizzyCTS · Oct 12, 2011 at 04:48 PM · multiplayeriphonemultiplayer-networkingudpmultiplayer-tutorial

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

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

2 Replies

· Add your reply
  • Sort: 
avatar image
3
Best Answer

Answer by lizzyCTS · Oct 28, 2011 at 06:00 PM

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); 
 to
 
         byte[] sendData = encode.GetBytes(ip); 

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

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by ThiagoSCF · Dec 14, 2012 at 08:32 PM

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

Thank you very much

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

3 People are following this question.

avatar image avatar image avatar image

Related Questions

convert standard firstpersoncharacter into multiplayer 2 Answers

How do i make multiplayer for my game? 0 Answers

Unity Multiplayer Oyun Yapma 0 Answers

Setting up a GUI System for room selection , Multiplayer (Photon/Unet) 1 Answer

,UI Button in multiplayer Networking Game is not working...... 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges