Haptic animation playback
Windows · Unity 6000.0.44f1 · Plugin 2.6.0 · Requires Teslasuit Studio
This example plays a haptic animation authored in Teslasuit Studio. It loads a .ts_asset animation, gets a playable from the haptic player, and plays it on the connected suit. The scene is TS/Examples/Scenes/Haptic/HapticAnimationPlayback.unity.
What it demonstrates#
- Importing a
.ts_assethaptic animation as aTsHapticAnimationAsset. - Getting a device-bound playable from
TsHapticPlayer.GetPlayable. - Playing the animation on the suit.
Scene setup#
The scene has one GameObject that represents the suit. It carries a TsSuitBehaviour (a TsDeviceBehaviour) for device discovery, and a TsHapticPlayer, which requires the device behaviour on the same object. A small demo script holds a reference to the imported animation asset and to the player, and triggers playback.
When the suit connects, TsHapticPlayer captures the device's IHapticPlayer interface. From then on GetPlayable can turn an imported asset into an IHapticPlayable bound to that device.
The key API pattern#
public class HapticAnimationPlayback : MonoBehaviour
{
[SerializeField] private TsHapticPlayer m_player; // on the suit object
[SerializeField] private TsHapticAnimationAsset m_animation; // imported .ts_asset
public void Play()
{
// Instance loads the native asset on first use.
IHapticPlayable playable = m_player.GetPlayable(m_animation.Instance as IHapticAsset);
playable?.Play();
}
}GetPlayable returns null until a device is connected, so the demo triggers playback from a button or after connection rather than in Start. The asset's Instance property lazily loads the native asset the first time it is read, as described in TsAssetBase.
Safety. Confirm the suit is calibrated before playing. Studio animations can drive several channels at once, so start with a low-intensity animation.
What to read next#
- Haptic assets: the bundled
.ts_assetfiles you can play this way. TsHapticPlayerreference: full API forGetPlayableandCreateTouch.- Playing touches: build a playable in code instead of loading one.
