1
0
mirror of https://github.com/xiaopeng12138/MaiDXR.git synced 2025-02-15 18:32:34 +01:00
MaiDXR/Assets/Scripts/Controller.cs

23 lines
618 B
C#
Raw Normal View History

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
}
}