Controllers

Introduction

If you want to use controllers from a UnityXR-compatible device you may see that they don't move or hands are shown displaced or offsetted from the controller. This is because your device does not appear in the list UnityXRControllerTracker.compatibleDevices but you can add it to the list easily.

UnityXR provides position and rotation of the controller but hand wrist position and rotation will depend on the shape of the controller and cannot be estimated universally only from controller position and rotation. This is the reason each device will need a different offset that represent how offsetted is the wrist relative to the controller.

Adding a device

First of all you will have to use this controller in Unity Editor. HPTK singleton is configured by default to use PoseSkeletonTracker on UnityEditor which means hands will reman static performing some pose or animation but won't use controllers. To change this, replace PoseSkeletonTrackers with UnityXRControllerTrackers in HPTK singleton (HPTK.{left|right}EditorIDP). You can find more info about how to do this here.

Once you are using IDPs for UnityXR-compatible controllers, start Play Mode and open inspector window for any of the UnityXRControllerTracker components. Check the text shown in log field. It should show something like Manuf:[{device.manufacturer}] Name:[{device.name}]. Copy that text and stop Play Mode.

Then, add a new compatible device. Type its manufacturer and device name. Create a new empty GameObject under this UnityXRControllerTracker and reference it in the field wristOffset of the new compatible device. The Transform of this new GameObject will represent the offset that will be applied to hand wrist relative to controller.

Calibration

Hands now should move with controllers but they probably don't match your real hands. This means the wrist offsets are wrong and require calibration. In Play mode, move the GameObjects that represent the offsest of wrist relative to controller until virtual and real hand wrist match. Once they match, copy local position and local rotation from the offset Transform, stop Play mode and paste them in that Transform.

If you can't modify offsets from Unity Editor, you can do it on build using Debug package. Debug package includes a scene called ControllerCalibrationTool for this specific purpose. To import this package go to HPTK toolbar menu and then Integration Manager. One of the options should be Debug.

Last updated