GMU:Tutorials/Networking/Explaining the OSCReciever Script from The Captury to Unity: Difference between revisions

From Medien Wiki
Line 40: Line 40:
<br>
<br>
The '''OnDisable''' function will close the UDP sockets of the listener
The '''OnDisable''' function will close the UDP sockets of the listener
<br>
<br>
<br>
[[File:oscreciever6_new.png]]
[[File:oscreciever6_new.png]]

Revision as of 16:23, 30 June 2016

OSCReciever.js

Explanation

The following script I will provide contains the whole setup you need to recieve data from The Captury and constantly updating it in Unity

Step1

In RemoteIP we set our connection for example to the sever we want to recieve the messages from or we can test it locally:

Local: 127.0.0.1
The Captury: kosmos.medien.uni-weimar.de

SendToPort: is where we type in the UDP Port set in The Captury. Actually it's -- 1065 --
ListenerPort: can also be 1065.

The gameReciever variables is where you can drop your 3d object in later. You can define as many as you want.

Oscreciever1 new.png

Step2

Before we go further we have to first set up variables for each coordinate because those will recieve values from the OSCMessage
For "Person_One" for example we use x1 / y1 / z1

Oscreciever2.png

Step3

In this start function wie call both scripts: OSC and UDPPacketIO.

Oscreciever3 new.png

The OnDisable function will close the UDP sockets of the listener

Oscreciever6 new.png

Step4

This is our Update Function:
All values which will be parsed from Step5 will be constantly updated here.
We can now chose even if we want the objects to be transformed or rotated or whatever.
The Time.frameCount will constantly resubscribe every 60 frames. The first value means the framrate the last one the scale factor.

Subscription: instead of the Root you can use any bone described in The Captury. E.g.: Left_Arm

NOTICE: yourname etc. is just set up in the Script for comprehension. Please replace it with the name you set up in The Captury.(User_Green_Socket)

Oscreciever4 new.png

Oscreciever5 new.png

Step5

In our last step we define which values we want from the captury to parse them in the update function.
Also be aware to change the name of "Person_One" to the one you use in The Captury as mentioned above.

Oscreciever5.png