2022-01-16 16:35:31 +01:00
|
|
|
using System.Collections;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using UnityEngine;
|
|
|
|
using UnityEngine.XR;
|
|
|
|
public class Controller : MonoBehaviour
|
|
|
|
{
|
|
|
|
// Start is called before the first frame update
|
2022-03-09 20:52:38 +01:00
|
|
|
public XRNode Hand;
|
|
|
|
InputDevice device;
|
2022-01-16 16:35:31 +01:00
|
|
|
public float duration;
|
|
|
|
public float amplitude;
|
|
|
|
private void OnTriggerEnter(Collider other)
|
|
|
|
{
|
2022-03-09 20:52:38 +01:00
|
|
|
device = InputDevices.GetDeviceAtXRNode(Hand);
|
|
|
|
device.SendHapticImpulse(0, amplitude, duration);
|
2022-01-16 16:35:31 +01:00
|
|
|
}
|
|
|
|
private void OnTriggerExit(Collider other)
|
|
|
|
{
|
2022-03-09 20:52:38 +01:00
|
|
|
device = InputDevices.GetDeviceAtXRNode(Hand);
|
|
|
|
device.StopHaptics();
|
2022-01-16 16:35:31 +01:00
|
|
|
}
|
|
|
|
}
|