Quantcast
Channel: Questions in topic: "clone"
Viewing all articles
Browse latest Browse all 508

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

$
0
0
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 (); } }

Viewing all articles
Browse latest Browse all 508

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>