TeslasuitDocumentation
Plugins

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.

ParameterRangeMeaning
frequency0 to 150Touch frequency in Hz.
amplitude0 to 100Stimulation strength as a percentage of the calibrated range.
pulseWidth0 to 320Pulse width in microseconds.
durationmillisecondsHow 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.