<aside> 📄 This script resets the scene when the right trigger key is pressed.
</aside>
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.XR;
public class ResetSceneOnRightTrigger : MonoBehaviour
{
public float triggerThreshold = 0.8f;
public float cooldownTime = 1.0f; // seconds before you can reload again
private float lastReloadTime = -10f;
void Update()
{
InputDevice rightHandDevice = InputDevices.GetDeviceAtXRNode(XRNode.RightHand);
if (rightHandDevice.isValid)
{
if (rightHandDevice.TryGetFeatureValue(CommonUsages.trigger, out float triggerValue))
{
if (triggerValue > triggerThreshold && Time.time - lastReloadTime > cooldownTime)
{
SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex);
lastReloadTime = Time.time;
}
}
}
}
}