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

From Medien Wiki

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

Here is the File: OSC_Reciever.js

IMPORTANT

Be aware that the OSC and the UDPPacketIO Scripts are in the Folder called Plugin
Also be sure to not have the Scripts twice in the Unity Assets Folder.

Create an Empty GameObject were you put all three Scripts in and call it as you like e.g. OSCHandler.

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.

The controller variable isn't important for us. Don't confound it with the gameReciever tab in your editor.

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 are our Update Functions:
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.

Oscreciever10 new.png