API reference
API reference
Select your platform
No SDKs available
No versions available

HapticSource Class

Extends MonoBehaviour, ISerializationCallbackReceiver
Provides playback functionality for a single haptic clip by wrapping HapticClipPlayer.
If you don't need a MonoBehaviour and a C# class would be more suitable, use HapticClipPlayer instead. It has the same functionality.
Once you have assigned a HapticClip to the clip property you can play the HapticSource, enable or disable looping, and modulate the amplitude and frequency.
You can place multiple HapticSource components in your scene, with a different HapticClip assigned to each.

Properties

Assigns a HapticClip to this HapticSource.
See also: PlayFromStart.
Assigns a physical controller to this HapticSource that haptics should output to.
The controller will only be applied the next time PlayFromStart() is called. It can also be assigned as an argument to PlayFromStart if preferred.
bool loop[Get]
Sets/gets the HapticSource's amplitude.
See HapticClipPlayer.amplitude for details.
Sets/gets the HapticSource's frequency shift.
Sets/gets the HapticSource's playback priority.
See HapticClipPlayer.priority for details.

Fields

The duration of the assigned HapticClip in seconds.

Member Functions

Starts playback of the HapticClip that has been assigned with the clip property from the start of the clip.
All properties applied to this HapticSource will be effective during playback. Although multiple HapticSources can play simultaneously, the output of only one will be felt at any given moment on a given controller. See HapticClipPlayer.priority for a description of how this works.
Starts playback of the HapticClip that has been assigned with the clip property:
The controller assigned to this HapticSource will be reassigned to the one passed to this method. All properties applied to this HapticSource will be effective during playback. Although multiple HapticSources can play simultaneously, the output of only one will be felt at any given moment on a given controller. See HapticClipPlayer.priority for a description of how this works.
  1. From the start of the clip
  2. On the controller passed by argument
Parameters
controller
The physical controller to play haptics on.
Stops playback of the HapticSource.
Serialization callback from the ISerializationCallbackReceiver interface. Unused for now but declared to fulfill the interface.
Serialization callback from the ISerializationCallbackReceiver interface. HapticSource uses it to synchronize the properties of the wrapped HapticClipPlayer to the serializable fields on this HapticSource. This occurs whenever a user updates any of the values on the custom inspector or whenever Unity loads the persisted data.

Protected Functions

Ensures that the lifetime of the wrapped HapticClipPlayer matches that of the HapticSource.
Did you find this page helpful?
Thumbs up icon
Thumbs down icon