Utilities for using a Vive Tracker without HMD
There are several reasons why one would want to use Vive Trackers and Controllers without a headset. These devices are sub-millimetric positional trackers, which are useful for dozens of applications: low-cost motion capture, marker-less camera tracking, pointing devices, althlete performance assesment, among others. Unfortunately, this use case is not officially supported by Valve so many of Valve’s tools (like the Vive Input asset) do not work if one has the headset disconnected. Valve’s staff will not answer any questions regarding these topics on Viveport forums. This document is a guide to using HTC Vive Tracker’s without the headset in Unity.
The scripts in this package will allow you to:
Download the Unity package from here.
This package works with SteamVR version 1.2.3, which is an old release. Get it from here. If you get the latest version (currently 2.2.0) you will be able to use the Vive Tracker, but not the controllers. If you only want to use the Vive Tracker, you’re fine with version 2.2.0, but you may have to delete the files that have compile errors. Download and import the SteamVR package before downloading this project or package.
Make sure Virtual Reality Supported is unchecked in Unity’s player settings. This is important. If checked, Unity will crash. Also, uncheck the “Automatically Enable VR” checkbox in Unity’s preferences (SteamVR section).
The SampleScene uses a tracker to interact with a UnityUI. If you click on the Record Data toggle, the data from your controller will be recorded to a .json file.
Use the ButtonListener example as a starting point if you want to use button clicks on MonoBehaviours.
The ControllerEvent script, which should be added to the controller gameobject (which as a SteamVR_TrackedController component), sends Raycasts to the objects in its layerMask. In the examples, the layer is called “VR_UI”. Therefore, you should follow these steps to interact with UI objects:
If you want to build your project, you must assure the openvr_api.dll is included in the Plugins folder of your build. You can copy it manually. Otherwise, edit the CopyOpenVR.cs script and point it to the correct location and it will be done automatically.
Note for recent version of Unity (Tested with 2019.3.0f1): If Unity complains that openvr_api.dll is not present, you have to import the OpenVR package using the Package Manager.