I am trying to set simple bindings for trackers so I may access pogo pin states in game.
Currently I have set all of my trackers to role: “Disabled” and created bindings for: application_generated_unity_mygame_binding_vive_tracker.json.
But in Unity I am unable to see any actions values from the trackers and they never change.
If I set the trackers to role: “camera”, “chest” or other similar then I can only have option to change the “Power” button action. so pogo pins are missing.
Why did they make it impossible to use trackers?
How do I get around this limitation
[UPDATE]
Strange stuff here,
If I change a tracker to role: “camera” then immediately change it back to “disable” I see it remains as “/user/camera -vive_tracker” in the debugger.
During this time all of my bindings work! But only for that one tracker
I am guessing that SteamVR is bugged out, somehow this one tracker is not a disable/camera mix???
But worse yet, it’s a total hack, and I would never ask my customers do this.
Why does this just seem so broken? Was it intentional?
Try setting them to be handed. I don’t use SteamVR 2.0, but when implementing the trackers through OpenVR internally, we found we would only get data from the pins when the tracker was being treated like a controller and set to be handed.
Thank you for your advice. though I have tried handed, which kind of worked, but then I ran up against the issue of handType uniqueness.
I add a hand.cs script to each tracker (dynamically), which requires me to set it’s handType. But if two trackers share the same handType then it is impossible to read the IO from a specific tracker (I think).
The only way I was able to make two trackers work independently was to create redundant bindings for ‘camera’ and ‘keyboard’ roles, then in Unity using OpenVR I check the device type via ETrackedDeviceProperty.Prop_ControllerType_String property to see if it is reporting as a ‘vive_tracker_camera’ or ‘vive_tracker_keyboard’. This allows me to set the handType within a switch statement for all trackers when I dynamically adding the hand.cs script.
[Header ("VIVE TRACKERS")]
public Transform[] viveTrackers;
public LayerMask trackersHoverMasks; //layers that this tracker can hover onver
public void SetupTrackers() {
foreach (Transform viveTracker in viveTrackers) {
SteamVR_TrackedObject device = viveTracker.GetComponent<SteamVR_TrackedObject> ();
var deviceType = GetDeviceType (device);
if (!deviceType.ToLower().Contains ("tracker") || device.index == null || !device.isValid) {
continue;
}
var trackerPrefab = Instantiate<GameObject> (TrackerLinkerPrefab, viveTracker);
switch (deviceType) {
case "vive_tracker_camera":
AddHandTypedTracker(trackerPrefab, SteamVR_Input_Sources.Camera);
break;
case "vive_tracker_keyboard":
AddHandTypedTracker(trackerPrefab, SteamVR_Input_Sources.Keyboard);
break;
case "vive_tracker":
if (trackerPrefab.GetComponent<Hand> ()) {//maybe it changed during gameplay?
Destroy (trackerPrefab.GetComponent<Hand> ());//destroy the hand
}
break;
}
}
}
string GetDeviceType (SteamVR_TrackedObject device) {
var error = ETrackedPropertyError.TrackedProp_Success;
var result = new System.Text.StringBuilder((int)64);
var capacity = OpenVR.System.GetStringTrackedDeviceProperty((uint)device.index, ETrackedDeviceProperty.Prop_ControllerType_String, null, 0, ref error);
if (capacity > 1)
{
result = new System.Text.StringBuilder((int)capacity);
OpenVR.System.GetStringTrackedDeviceProperty((uint)device.index, ETrackedDeviceProperty.Prop_ControllerType_String, result, capacity, ref error);
}
return result.ToString ();
}
void AddHandTypedTracker(GameObject trackerSphere, SteamVR_Input_Sources trackerType) {
var hand = trackerSphere.AddComponent<Hand> ();
hand.hoverLayerMask = trackersHoverMasks;
hand.hoverSphereRadius = 0.17f;
hand.useFingerJointHover = false;
hand.handType = trackerType; //now set the handType for this tracker
}
It seems wasteful though to have to create the exact same bindings for all the roles: keyboard, camera, shoulders, waist, feet, so on… just so Unity/SteamVR may access tracker’s actions individually.