- Home /
Question by
neosurreal · Jul 16, 2017 at 01:03 PM ·
controllerhaptic
Can't get TriggerHapticPulse to work!
Hi,
I was following a tutorial on Youtube and I can't get it to work. I just simply want the controller to touch and object and have it trigger a haptic feedback. I've checked the VRTK, etc. and I don't want to use another object to trigger the response, but directly by the controller. This is the code provided by the tutorial. Any help would be much appreciated.
using System.Collections;
using UnityEngine;
public class HapticTouch : MonoBehaviour {
public bool hapticFlag = false;
private SteamVR_TrackedObject trackedObject;
private SteamVR_Controller.Device device;
void Start ()
{
trackedObject = GetComponent<SteamVR_TrackedObject>();
}
void Update ()
{
device = SteamVR_Controller.Input((int)trackedObject.index);
if(hapticFlag)
{
device.TriggerHapticPulse(500);
}
}
void OnTriggerEnter()
{
hapticFlag = true;
}
void OnTriggerExit()
{
hapticFlag = false;
}
}
Comment