SetControllerVibration()
from OVRInput to start and stop haptics for a controller.SetControllerVibration()
in the frame you want to make the change.static void OVRInput.SetControllerVibration(float frequency, float amplitude, Controller controllerMask)
Controller
are defined in the Developer Reference.// starts vibration on the right Touch controller
OVRInput.SetControllerVibration(1, 1, OVRInput.Controller.RTouch)
public enum InteractionProfile
{
None = OVRPlugin.InteractionProfile.None,
Touch = OVRPlugin.InteractionProfile.Touch,
TouchPro = OVRPlugin.InteractionProfile.TouchPro,
}
OVRPlugin.InteractionProfile.Touch
: Oculus Quest Touch ControllerOVRPlugin.InteractionProfile.TouchPro
: Meta Quest Touch Pro Controllerpublic enum HapticsLocation
{
None = OVRPlugin.HapticsLocation.None,
Hand = OVRPlugin.HapticsLocation.Hand,
Thumb = OVRPlugin.HapticsLocation.Thumb,
Index = OVRPlugin.HapticsLocation.Index,
}
HapticsLocation
enum.OVRPlugin.HapticsLocation.Hand
: main haptics location with VCMOVRPlugin.HapticsLocation.Thumb
: haptics location on the thumb with LRAOVRPlugin.HapticsLocation.Index
: haptics location on the trigger with LRApublic struct HapticsAmplitudeEnvelopeVibration
{
public int SamplesCount;
public float[] Samples;
public float Duration;
}
Field | Description |
---|---|
Samples | A float array representing the amplitude envelope values. |
SamplesCount | The number of elements in the ‘Samples’ array. |
Duration | A float value representing the duration of the haptic effect in seconds. |
public struct HapticsPcmVibration
{
public int SamplesCount;
public float[] Samples;
public float SampleRateHz;
public bool Append;
}
Field | Description |
---|---|
Samples | A float array. Represents the haptic feedback samples. If you consider the haptic effect as a sampled analog audio, then this buffer will contain the samples representing that effect. |
SamplesCount | The number of samples in ‘Samples’ array. |
SampleRateHz | A float value representing the number of samples to be played from ‘Samples’ per second. This is used to determine the duration of the effect. |
Append | To support long haptic effects, set this flag to true , which means that the effect will be played after the currently-playing effect is finished. If append is false , then the provided effect will begin playing immediately. |
public static void SetControllerLocalizedVibration(
HapticsLocation hapticsLocationMask,
float frequency,
float amplitude,
Controller controllerMask = Controller.Active)
hapticsLocationMask
: represents the location where the effect will be played. See ‘HapticsLocation’ enum for more details.frequency
: float value representing the frequency of the effectamplitude
: float value representing the amplitude of the effectpublic static void SetControllerHapticsAmplitudeEnvelope(
HapticsAmplitudeEnvelopeVibration hapticsVibration,
Controller controllerMask = Controller.Active)
public static int SetControllerHapticsPcm(
HapticsPcmVibration hapticsVibration,
Controller controllerMask = Controller.Active)
GetControllerSampleRateHz
function and generate the haptics data based on this sampleRate
.public static float GetControllerSampleRateHz(Controller controllerMask = Controller.Active)
public static OVRInput.InteractionProfile GetCurrentInteractionProfile(OVRInput.Hand hand)