If you have an HTC Vive Tracker, you may have already hooked it up and started tracking objects in Unity3D. That part isn’t too hard, and it’s a lot of fun. But you can also flip that Vive Tracker over and start using the POGO pins on the back. The pins are pretty easy to use and give you access to the same buttons you’d have on a normal Vive wand and even include an output for haptic feedback.
HTC Vive Tracker Documentation
To get detailed info, HTC has a guide here: https://dl.vive.com/Tracker/Guideline/HTC_Vive_Tracker_Developer_Guidelines_v1.3.pdf
Setting up the HTC Vive Tracker in Unity3D
I’ve gone over it already and just wanted to share the steps involved to get going.
First, you need your tracker in-game. To keep it simple, we’ll use the CameraRig prefab.
Drop a [CameraRig] into an empty scene (and delete the existing maincamera).
Under the CameraRig, add an empty gameobject and name it “Tracker“.
Add the SteamVR_TrackedObject component to the “Tracker” you’ve just created.
Select the [CameraRig].
Drag the “Tracker” to the Objects array on the SteamVR_ControllerManager.
Turn on both controllers and press play.
Move the tracker around, if you see it move in-game, you’re good to move on to the next part.
Reading Vive Tracker POGO Pins
To show how to read the inputs, I’ve created this example script. Put it in your project, then add it to the “Tracker” object.
Start playing again and make sure the Tracker is still moving (remember both controllers need to be on too).
Now let’s take a look at the image from the official documentation.
If you’re not familiar with electronics, don’t worry, this one’s pretty simple.
All you need to do is make a connection from GND (Pin 2) to whichever pin you want to trigger.
You can do this with a single wire, or ideally hook it up to a switch that’s attached to your physical device.
To test this, simply touch pin 2 & pin 4 with the same wire, and you’ll see the “Trigger” field set to true.
- 2 – Ground
- 3 – Grip
- 4 – Trigger
- 5 – Trackpad
- 6 – Menu Button
Hooking up Hardware
If you’re not sure what to use, try digging out an old electric nerf gun like this: http://amzn.to/2uDRI9b (or find a broken used one on craigslist for free/cheap)
Rip it apart and hook up the wires coming from the trigger to the tracker’s pogo pins.
There are a few different adapters out there you can order/print, like this: https://www.thingiverse.com/thing:2127180 – It’d probably be a good idea to have some sort of adapter in there to make pin access easier…