PlayAdvanced
is a versatile Unity method designed for playing parametric haptic effects. This method enables the creation of complex haptic patterns using specified parameters for amplitude, pitch, and transient effects, offering a high degree of customization for tactile feedback.
Parameters:
_amplitude
: An array of amplitude values formatted as Time-Value pairs. Each pair defines the strength of the haptic effect at a specific moment._pitch
: An array of pitch values also formatted as Time-Value pairs. These define the ‘sharpness’ or ‘buzziness’ of the haptic effect over time._freqMin
(optional): The minimum frequency (or lowest pitch) that the haptic effect can reach._freqMax
(optional): The maximum frequency (or highest pitch) achievable in the haptic effect._transient
: (optional) An array of transient values formatted as Time-Amplitude-Pitch triplets. Transients add momentary spikes or bursts to the haptic pattern._intensity
(optional): Overall intensity of the haptic effect._loops
(optional): Number of times the haptic pattern should loop._controllerSide
(optional): Side of the controller where the haptic effect should occur.- LateralFlag.Global (default): plays on both sides of the controller (only option on mobile devices – Android | iOS)
- LateralFlag.Left: plays on the left side of the controller
- LateralFlag.Right: plays on the right side of the controller
Usage:
PlayAdvanced
is used when you need a nuanced and dynamic haptic pattern. By providing arrays for amplitude, pitch, and optionally transient effects, you can tailor a highly specific haptic experience.
// Amplitude at 0.5 between 0 and 2 seconds
double[] amplitudes = {
1.0, 0.5,
3.0, 0.5
};
// pitch between 0 and 1
double[] pitch = {
1.0, 1.0,
3.0, 0.0
};
HAR.PlayAdvanced(amplitudes, pitch);
// Amplitude array
double[] amplitudes = {
0.0, 0.0,
1.0, 1.0,
2.0, 0.5,
3.0, 0.25,
4.0, 0.25
};
// pitch array
double[] pitch = {
0.0, 1,
2.0, 0,
4.0, 1
};
// transient array
double[] transients = {
0.5, 1, 0.5,
3.5, 0.5, 0.5
};
double _fmin = 30;
double _fmax = 400;
HAR.PlayAdvanced(amplitudes, pitch, _fmin, _fmax, transients);
Example: Increasing and decreasing amplitude with a longer tail. The pitch is swiped from max to min back to max to create a “bomb dive” effect. The frequency range is expanded to take advantage of specific controller haptics capabilities like DualSense.
Practical Application:
PlayAdvanced
is particularly beneficial in scenarios where detailed haptic feedback is essential.The ability to control the amplitude, pitch, and transient aspects allows developers to craft a haptic experience that closely matches the intended virtual interaction.