viveTrackersUnityXRI is a Unity package that enables the use of SteamVR trackers in Unity XRI 3 and simplifies the process of matching real objects with virtual ones through easy calibration.
- SteamVR tracker integration with Unity XRI 3
- Calibration of offset between real objects and trackers
- Room-scale area alignment with screens
- Support for multiple trackers and real objects (with or without HMD)
- Compatible with 12 SteamVR tracker roles
- Virtual Production (see https://github.com/yaelmartin/screenPerspective)
- Training simulation, games (with or without HMD)
Left Foot | Right Foot | Waist |
Left Shoulder | Right Shoulder | Chest |
Left Elbow | Right Elbow | Camera |
Left Knee | Right Knee | Keyboard |
Note: For single tracker use, the VTSingle preset is available. However, when multiple trackers are active, use dedicated presets to avoid mixed positional data.
Assuming you only need to use trackers inside Unity without the other features of this project,
-
Import the following from the package:
- ViveTrackers.inputactions
- HTCViveTrackerHapticProfile.cs
- Preset folder
- Resources folder
-
Add the trackers interaction profile:
- Go to Edit → Project Settings → XR Plug-in Management → OpenXR
- Under Enabled Interaction Profiles, click '+' and select "HTC Vive Tracker Profile"
-
In your scene hierarchy:
- Find your InputActionManager
- Add ViveTrackers.inputactions to its Action Assets
-
Place a tracker prefab with a role (e.g., TrackerKeyboard) as a child of XROrigin → Camera Offset
- Ensure you are using Unity Editor 2021.3 or higher
- Install "XR Interaction Toolkit" version 3 from the Package Manager
- Import the latest viveTrackersUnityXRI.unitypackage
- Add the trackers interaction profile (as described above)
- Use prefabs from Assets → Tracker → Demos in your scene and unpack them
Proper calibration ensures accurate representation of real objects in the virtual space.
- Ideally use a 1:1 CAD model or 3D scan of your real object as the virtual irlObjectWithTracker
- Place your model inside MovableArea
- Select TrackerOperations and link your model to the irlObjectWithTracker field in the inspector
- Position the "Spawn" (pink T-shaped object) where the tracker would be on your real object
- Click Play and place your real object in front of your screen
- Use the sliders to align the yaw axis
- Recenter the tracker
Tips:
- Make forward and backward motions while viewing the bottom orthographic view
- Use a VR headset with passthrough to verify offset accuracy
After calibration:
- Save the offset (creates a .json file in the StreamingAssets folder)
- The configuration will load automatically on Play if the file exists
- Add the component TrackerConfigLoader.cs to a tracker prefab (e.g., VTSingle, TrackerCamera)
- Change the filePath field to use your configured file
- Edit C:\Program Files (x86)\Steam\config\steamvr.vrsettings
- Add the following to the "steamvr" section:
"requireHmd": false, "forcedDriver": "null", "activateMultipleDrivers": true
- Add the following to the "dashboard" section:
"enableDashboard": false
- Use nullDriverEnable.ps1 or nullDriverDisable.ps1 by right-clicking and selecting "Run with PowerShell"
Note: To fix a Unity Editor and SteamVR null driver bug that freezes Windows, edit the following file: C:\Program Files (x86)\Steam\steamapps\common\SteamVR\drivers\null\resources\settings\default.vrsettings
Remove these lines:
"windowX": 0,
"windowY": 0,
"windowWidth": 2160,
"windowHeight": 1200,
-
HTCViveTrackerProfile.cs from Vive's forums and haptics from https://github.com/mbennett12/ViveTrackerHapticOpenXR
-
FreeFlyCamera.cs from Sergey Stafeev