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
0
Question by tohmjudson · Jan 14, 2014 at 04:07 AM · cloneudpmax

Optimization Help...Sending UDP Data from Clones to Max

HI all,

I have the following script (below), which is sending cloned planet prefab position data from Unity into Max via UDP. I am receiving all data fine, as long as I only have 3 or 4 clones. When I get to 9, everything bogs down hard. While all the data is getting there, it is behind by several seconds.

For the record: I need this to be on clones that will be generated by visitors to the exibition. I couldn't get the mu tools from VT to work with clones.

For testing, you can attach this to any object and receive in Max with a mxj net.udp.recv @port 7474

Can any of you guru's help me optimize this to lose the drag? Should I funnel or limit the packets?

Thank you so much in advance!

 using UnityEngine;
 using System.Net.Sockets;
 using System.Net;
 using System.Text;
 using System.Collections;
 
 
 public class UdpServer_Position : MonoBehaviour
 {
     public string hostName = "127.0.0.1";
     public int port = 7474;
 
 
     private UdpClient server;
     private ASCIIEncoding byteEncoder = new ASCIIEncoding();
     
     
     // Real-time data //
     void Update () 
     {
         server = new UdpClient(hostName, port);
         server.Connect( hostName, port );
 
         SendFloat (gameObject.name + " " + "X", transform.position.x);
         SendFloat (gameObject.name + " " +  "Y", transform.position.y);
         SendFloat (gameObject.name + " " +  "Z", transform.position.z);
     }
 
 
     // Sends an Float value to Max //
     public void SendFloat(string maxRouteArgument, float val)
     {
         string message = maxRouteArgument + " " + val;
         byte[] messageBytes = byteEncoder.GetBytes( message );
         SendBytes( messageBytes );
     }
 
     private void SendBytes( byte[] message )
     {
         try
         {
             server.Send( message, message.Length );
         } 
         catch( SocketException e )
         {
             Debug.LogError( e );
         }
     }
 
     // Close server on exit //
     void OnApplicationQuit()
     {
         server.Close ();
     }
 }
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

0 Replies

· Add your reply
  • Sort: 

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

18 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

getting udp package info inside unity (GlovePIE) 0 Answers

How can I receive UDP messages or similar in WebGL? 1 Answer

Importing Character with animation into unity? 1 Answer

Do I need 3ds max??? 2 Answers

Bringing visibilty and material animation from Max to Unity 3 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