Develop
Develop
Select your platform

Haptic Feedback

Updated: Sep 4, 2024

Overview

While Haptics Studio and Haptics SDK are the recommended path for haptics on Quest, there are a number of other haptics APIs available in the runtime. These provide lower-level control to your application and may be useful in some specific contexts. You may consider these APIs when building custom middleware integrations, or when employing controller specific APIs, like adding localized haptics on Touch Pro controllers.
This guide describes how to use Unreal Blueprints to control haptic effects on Touch controllers.

Unreal Simple Haptics

Use the Set Haptics by Value Blueprint to start and stop haptics for a controller.
To start, update, or end vibration call Set Haptics by Value in the frame you want to make the change and define the frequency and amplitude of the haptic response.
Expected values for amplitude and frequency are any value between zero and one, inclusive. The greater the value, the stronger or more frequent the vibration in the controller. To end the vibration, set both amplitude and frequency to 0. Controller vibration automatically end 2 seconds after the last input.
Meta Quest Touch Pro supports three different haptics locations: hand, thumb and index. While Meta Quest Touch supports hand only.

PCM Haptics

Given a sound wave, this function will split the sound wave into multiple batches. Each batch will be sent to the controller with one frame. First send’s append argument is set by the Blueprint. All other sends’ append arguments are set to true.
  • Note: A CVar can be added to BaseDeviceProfiles.ini to control the duration of each PCM batch. It can be set with the below example. Default value is 36ms. +CVars= r.Mobile.Oculus.PCMBatchDuration = 36
    One example is, given a soundwave with sample rate 2000 and default PCMBatchDuration (36ms), the batch size will be 2 (samples/ms) * 36ms = 72 samples.
    A large PCMBatchDuration will cause worse CPU overhead. On the other hand, if PCMBatchDuration is too low compared to frametime, haptics data could be dropped.
  • Note: In Unreal Engine 5, to use a soundwave as a haptic effect, the soundwave’s LoadingBehavior must be set as Force Inline.

Amplitude Envelope

All amplitudes data will be sent to the controller with one shot and duration is calculated per the given sample rate in the Blueprint. This duration should not be greater than the return value of Get Max Haptics Duration.
Note: Larger data will cause more CPU overhead which could further affect game performance. Details can be found at native documents.

Example

The following example shows some the Blueprints triggered by input mappings.
Unreal Blueprint input mapping

Buffered Haptics in Unreal Engine

Deprecated
The OVRHaptics API is deprecated and only included for legacy support purposes. The API was only supported on the original configuration Oculus Rift headset with external tracking sensors.
You may use the standard Play Haptic Effect Blueprint to send a specified haptic curve to the Touch or Xbox controller. For more information, see Unreal’s Play Haptic Effect guide.
Play Haptic Effects may be configured to play haptic waves based on three types of input. Right-click Content Browser to bring up the context menu, then select Miscellaneous. and select one of the following three options:
  • Haptic Feedback Buffer: Plays a buffer of bytes 0-255,
  • Haptic Feedback Curve: Draw the haptic linear curve you wish to play using the Haptic Curve Editor, or
  • Haptic Feedback Soundwave: Select a mono audio file to be converted into a haptic effect of corresponding amplitude.
The following Blueprint illustrates a simple haptics sequence on the Oculus Touch controller using Play Haptic Effect. This example sends vibrations using Play Haptic Effect when the left controller grip button is pressed. When the button is released, Stop Haptic Effect sends a stop command to the Touch controller.
When the left controller X button is pressed, a constant vibration is sent by Set Haptics by Value until the button is released. Note that Set Haptics by Value calls are limited to 30 Hz; additional calls will be disregarded.
For a sample that shows how to use Play Haptic Effects Blueprint, see the Input sample in the Unreal Samples.
Did you find this page helpful?