Playing touches
Windows · Unity 6000.0.44f1 · Plugin 2.6.0 · Requires Teslasuit Studio
This example builds a haptic touch in code instead of loading an authored asset. A touch is an atomic playable with constant parameters, created from frequency, amplitude, pulse width, and duration. The scene is TS/Examples/Scenes/Haptic/PlayingTouches.unity.
What it demonstrates#
- Creating a touch at runtime with
TsHapticPlayer.CreateTouch. - Setting the four touch parameters and their valid ranges.
- Playing the resulting dynamic playable on the suit.
Scene setup#
The scene mirrors the animation example: a suit GameObject carrying a TsSuitBehaviour for device discovery and a TsHapticPlayer. A demo script exposes the touch parameters in the inspector and calls CreateTouch when triggered. Because the plugin resolves channels through the device, the touch plays on the device's default channel group.
The key API pattern#
CreateTouch takes the four parameters and returns an IHapticDynamicPlayable.
[SerializeField] private TsHapticPlayer m_player;
public void PlayTouch()
{
// frequency [0:150], amplitude [0:100], pulseWidth [0:320], duration in ms
IHapticDynamicPlayable touch = m_player.CreateTouch(
frequency: 75,
amplitude: 50,
pulseWidth: 240,
duration: 3000);
touch.Play();
}Internally the player converts frequency to a signal period (period = 1000000 / frequency) and packs the values into haptic parameters, as shown in the TsHapticPlayer reference.
| Parameter | Range | Meaning |
|---|---|---|
frequency | 0 to 150 | Touch frequency in Hz. |
amplitude | 0 to 100 | Stimulation strength as a percentage of the calibrated range. |
pulseWidth | 0 to 320 | Pulse width in microseconds. |
duration | milliseconds | How long the touch plays. |
Safety. Amplitude is relative to the calibrated range, not the hardware maximum. Confirm calibration, then start low (for example amplitude 30, short duration) and increase gradually.
What to read next#
TsHapticPlayerreference: theCreateTouchsignature and parameter notes.- Haptics & EMS concept: touches, channels, and playables.
- Haptic animation playback: play an authored asset instead of a code-built touch.
