This repository has been archived on 2025-03-06. You can view files and clone it, but cannot push or open issues or pull requests.
2023-01-10 17:11:44 +01:00

40 lines
915 B
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.XR.Interaction.Toolkit;
public class hapticInteractable : MonoBehaviour
{
[Range(0,1)]
public float intensity;
public float duration;
// Start is called before the first frame update
void Start()
{
}
public void TriggerHaptic(BaseInteractionEventArgs eventArgs)
{
if(eventArgs.interactorObject is XRBaseControllerInteractor controllerInteractor)
{
TriggerHaptic(controllerInteractor.xrController);
}
}
public void TriggerHaptic(XRBaseController controller)
{
if(intensity>0)
controller.SendHapticImpulse(intensity, duration);
}
public void vibrate(float value)
{
Debug.Log("Wert: " + value);
if(intensity>0)
gameObject.GetComponent<XRBaseController>().SendHapticImpulse(intensity, value);
}
}