From ee82c726e0381420e57c5c3acdab7fd34b4661f9 Mon Sep 17 00:00:00 2001 From: marcgauch <34353267+marcgauch@users.noreply.github.com> Date: Thu, 7 Dec 2023 22:11:07 +0100 Subject: [PATCH] haptic feedback --- Assets/iamagun.cs | 23 +++++++++++++++++++++++ ProjectSettings/ProjectSettings.asset | 2 ++ 2 files changed, 25 insertions(+) diff --git a/Assets/iamagun.cs b/Assets/iamagun.cs index c9f6dcf..a9ff8ef 100644 --- a/Assets/iamagun.cs +++ b/Assets/iamagun.cs @@ -13,6 +13,11 @@ public class iamagun : MonoBehaviour private Vector3 offsetPosition; private Quaternion offsetRotation; + // Vibration variables + private float vibrationDelay = 0.05f; // Delay before the vibration starts + private float vibrationDuration = 0.5f; // Duration of the vibration + private float vibrationIntensity = 1.0f; // Intensity of the vibration + // Start is called before the first frame update void Start() { @@ -45,6 +50,24 @@ public class iamagun : MonoBehaviour { simpleShoot.StartShoot(); audio.Play(); + + // Trigger delayed and intense vibration feedback + StartCoroutine(TriggerVibration()); } } + + IEnumerator TriggerVibration() + { + // Wait for the specified delay before starting the vibration + yield return new WaitForSeconds(vibrationDelay); + + // Trigger vibration with the specified intensity + OVRInput.SetControllerVibration(1, vibrationIntensity, OVRInput.Controller.RTouch); + + // Wait for the specified duration + yield return new WaitForSeconds(vibrationDuration); + + // Stop the vibration + OVRInput.SetControllerVibration(0, 0, OVRInput.Controller.RTouch); + } } diff --git a/ProjectSettings/ProjectSettings.asset b/ProjectSettings/ProjectSettings.asset index 75fdc46..eefee64 100644 --- a/ProjectSettings/ProjectSettings.asset +++ b/ProjectSettings/ProjectSettings.asset @@ -139,6 +139,8 @@ PlayerSettings: bundleVersion: 0.1 preloadedAssets: - {fileID: 11400000, guid: 29d72bf9f28086693968cedbdc8f08cd, type: 2} + - {fileID: 11400000, guid: 541751c4fa90967d68ef779a22ee43f3, type: 2} + - {fileID: -3127938587913570544, guid: 8eb28e39ec717d0799039f01965f0533, type: 2} metroInputSource: 0 wsaTransparentSwapchain: 0 m_HolographicPauseOnTrackingLoss: 1