Unity Adapter

The first Unity adapter subscribes to information-hub status frames over WebSocket JSON. It uses no dedicated binary protocol and never touches IMU UDP data. The component drops stale frames by frame_id and interpolates a two-frame buffer using frame_time_ns.

Integration

  1. Start the information hub first; --status-hz 50 is recommended for Unity.

  2. Copy adapters/unity/Assets/WirelessImuMocap/MocapWebSocketClient.cs into the Unity project’s Assets/ directory.

  3. Add MocapWebSocketClient to a scene object.

  4. Set bodyRoot, then bind shoulder, elbow, wrist, palm, and fingertip Transforms for both leftRig and rightRig.

  5. Set hubUrl, for example ws://127.0.0.1:8765.

The coordinate mapping is fixed:

body_rh (X forward, Y left, Z up)
-> Unity (X right, Y up, Z forward)
Unity = (-body.Y, body.Z, body.X)

This is an axis permutation plus the necessary left/right sign conversion; it preserves the motion solver’s body_rh semantics. wear_side=left/right selects which rig is active, and only the current wearing side is displayed.

Limits

  • This version uses ClientWebSocket for Unity Editor and Windows/Linux/macOS standalone. WebGL needs a browser WebSocket implementation and is not included here.

  • Only status frames with frame=body_rh update the rig.

  • When frame_time_ns is missing, the latest frame still renders but is not time-interpolated. That indicates the source did not complete common-timeline alignment and its synchronization status should be investigated first.