- Home /
How to use the triggers on HTC Vive?
I have found some scripts online but they do not work at all. I have the the HTC Vive VR headset and trying to get the triggers to work, but I can't. Is there a good video out there that does what I want it to do? I have VRTK asset in my project and the Steam VR Plugin also in my project. The headset tracks but the controllers' triggers are not. I have this script, but it doesn't even show the in the console.
using System.Collections; using System.Collections.Generic; using UnityEngine;
public class TestTriggerViveController : MonoBehaviour {
public float triggerAxis;
private SteamVR_TrackedObject trackedObject;
private SteamVR_Controller.Device device;
// Use this for initialization
void Start ()
{
trackedObject = GetComponent<SteamVR_TrackedObject>();
}
// Update is called once per frame
void Update ()
{
device = SteamVR_Controller.Input((int)trackedObject.index);
triggerAxis = device.GetAxis(Valve.VR.EVRButtonId.k_EButton_SteamVR_Trigger).x;
float value = 1 - triggerAxis;
Debug.Log("Value is" + value);
}
}
is there a way to get it to work or should I just try a different script (there are no errors in this one). Would someone please show me how to get those freaking triggers to at least work in the console lol. I'm kind of a noob at this whole triggers thing. I would be clearer if that is needed. Thanks in advance if you help