How to make Quest 2 controller vibrate when shooting a gun.

This is a simple way to make the controller vibrate when shooting a gun.
Just call Vib().
You can change the length of the vibrate by changing the time variables in Invoke.

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Buzz : MonoBehaviour
{
    public float time = 3f;
    // Start is called before the first frame update


    // Update is called once per frame
    void Update()
    {
       
    }
    public void Vib()
    {
        Invoke("startVib", .1f);
        Invoke("stopVib", .4f);
    }
    public void startVib()
    {
        OVRInput.SetControllerVibration(1, 1, OVRInput.Controller.RTouch);
    }
    public void stopVib()
    {
        OVRInput.SetControllerVibration(0, 0, OVRInput.Controller.RTouch);
    }
}

Is this a question or guide?

Guide

1 Like

Hi @jdscogin
from below reference i found that quest pro controllers have three haptics(LRA) position.

But overinput.contrller have only R touch I think
public enum Controller
{
None = OVRPlugin.Controller.None, ///< Null controller.
LTouch = OVRPlugin.Controller.LTouch, ///< Left Oculus Touch controller. Virtual input mapping differs from the combined L/R Touch mapping.
RTouch = OVRPlugin.Controller.RTouch, ///< Right Oculus Touch controller. Virtual input mapping differs from the combined L/R Touch mapping.
Touch = OVRPlugin.Controller.Touch, ///< Combined Left/Right pair of Oculus Touch controllers.
Remote = OVRPlugin.Controller.Remote, ///< Oculus Remote controller.
Gamepad = OVRPlugin.Controller.Gamepad, ///< Xbox 360 or Xbox One gamepad on PC. Generic gamepad on Android.
Hands = OVRPlugin.Controller.Hands, ///< Left Hand provided by hand-tracking.
LHand = OVRPlugin.Controller.LHand, ///< Left Hand provided by hand-tracking.
RHand = OVRPlugin.Controller.RHand, ///< Right Hand provided by hand-tracking.
Active = OVRPlugin.Controller.Active, ///< Default controller. Represents the controller that most recently registered a button press from the user.
All = OVRPlugin.Controller.All, ///< Represents the logical OR of all controllers.
}
Can I know how to control each three part of the quest pro lra actuator?

This is an old thread, however, it was my first google result, so I wanted to share a little working example for the MetaQuestPro using only Unity.XR.
It will make the left controller vibrate for 1 second, I suppose in its maximum force.
About the comment above regarding the different actuators, I suppose you might be able to control them independently by changing the channel to send the impulse, but I haven’t tested that specifically yet.

                UnityEngine.XR.HapticCapabilities capabilitiesL;
                InputDevices.GetDeviceAtXRNode(XRNode.LeftHand).TryGetHapticCapabilities(out capabilitiesL);
                if (capabilitiesL.supportsImpulse)
                {
                    uint channel = 0;
                    float amplitude = 1.0f;
                    float duration = 1.0f;
                    InputDevices.GetDeviceAtXRNode(XRNode.LeftHand).SendHapticImpulse(channel, amplitude, duration);
                }

Cheers,