Streaming Motive OSC to Unity

While technically simple, the incoming data from Motive has to be transformed from a right-handed to a left-handed coordinate system. Check the NatNet2OSC wiki to stream Motive data to a specific IP address.

Use this library to stream OSC data in Unity:

Follow the instructions accordingly, to adjust the Unity C# receiving script.

using UnityEngine;
using System.Collections;

public class ReceivePosition : MonoBehaviour {
    public OSC osc;
    public string posAddress;
    public string quatAddress;

    // Use this for initialization
    void Start () {
	osc.SetAddressHandler( posAddress , onPosition );
        osc.SetAddressHandler( quatAddress , onQuaternion );
    void onPosition(OscMessage message){
        // Debug.Log(message);
        float x = - message.GetFloat(0);
        float y = message.GetFloat(1);
	float z = message.GetFloat(2);

	transform.position = new Vector3(x,y,z);

    void onQuaternion(OscMessage message){
        // Debug.Log(message);
	float qx =  message.GetFloat(0);
        float qy =  - message.GetFloat(1);
	float qz =  - message.GetFloat(2);
        float qw = message.GetFloat(3);

	transform.rotation = new Quaternion(qx,qy,qz,qw);
Last updated bystella speziali