Class HapticImpulsePlayer
Component that allows for sending haptic impulses to a device.
Inherited Members
Namespace: UnityEngine .XR.Interaction.Toolkit.Inputs.Haptics
Assembly: Unity.XR.Interaction.Toolkit.dll
Syntax
[AddComponentMenu("XR/Haptics/Haptic Impulse Player", 11)]
[HelpURL("https://docs.unity3d.com/Packages/com.unity.xr.interaction.toolkit@3.1/api/UnityEngine.XR.Interaction.Toolkit.Inputs.Haptics.HapticImpulsePlayer.html")]
public class HapticImpulsePlayer : MonoBehaviour
Properties
amplitudeMultiplier
Amplitude multiplier which can be used to dampen the haptic impulses sent by this component.
Declaration
public float amplitudeMultiplier { get; set; }
Property Value
Type | Description |
---|---|
float |
hapticOutput
Specifies the output haptic control or controller that haptic impulses will be sent to.
Declaration
public XRInputHapticImpulseProvider hapticOutput { get; set; }
Property Value
Type | Description |
---|---|
XRInput |
Methods
Awake()
See Mono
Declaration
protected void Awake()
OnDisable()
See Mono
Declaration
protected void OnDisable()
OnEnable()
See Mono
Declaration
protected void OnEnable()
SendHapticImpulse(float, float)
Sends a haptic impulse on the configured channel or default channel of the configured device.
Declaration
public bool SendHapticImpulse(float amplitude, float duration)
Parameters
Type | Name | Description |
---|---|---|
float | amplitude | The desired motor amplitude that should be within a [0-1] range. |
float | duration | The desired duration of the impulse in seconds. |
Returns
Remarks
This method considers sending the haptic impulse a success (and thus returns true)
if the haptic impulse was successfully sent to the device even if frequency is ignored or not supported by the device.
Uses the default frequency of the device.
SendHapticImpulse(float, float, float)
Sends a haptic impulse on the configured channel or default channel of the configured device.
Declaration
public bool SendHapticImpulse(float amplitude, float duration, float frequency)
Parameters
Type | Name | Description |
---|---|---|
float | amplitude | The desired motor amplitude that should be within a [0-1] range. |
float | duration | The desired duration of the impulse in seconds. |
float | frequency | The desired frequency of the impulse in Hz. A value of 0 means to use the default frequency of the device. |
Returns
Remarks
This method considers sending the haptic impulse a success (and thus returns true)
if the haptic impulse was successfully sent to the device even if frequency is ignored or not supported by the device.
Frequency is currently only functional when the OpenXR Plugin (com.unity.xr.openxr) package is installed
and the input action is using an input binding to a Haptic Control.