UCA Tutorial #2: Sensation Source Playback

Previous tutorial: Hello (Sensation) World

Next tutorial: Triggering Sensations with Hands


In this tutorial, we will look at the UCA’s Sensation Source Playback example. This introduces the Running property and shows how we can use helper functions, provided by the UCA, to control playback duration. We also show how a sensation’s haptic priority can be set.

Up and running

From the UCA’s Examples folder, open the SensationSourcePlayback scene and, ensuring your Ultrahaptics array is connected, hit play.

In the scene, click the checkboxes to trigger the associated haptics. For each sensation, both enabled and Running checkboxes must be checked to emit. As a Sensation Source begins emitting, any other emitting sensation is disabled.


Behind the scenes

Looking at the scene in more detail we see that it contains typical scene elements – Main CameraDirectional Light – plus the UltrahapticsKit prefab from our opening lesson. There are now three Sensation game objects – Sensation AB and C. There is also a canvas object containing the additional elements to hold text and controls to start and stop our sensations.

Any sensation emitting game object has a Sensation Source component. In our example, these are positioned 20cm above the centre of the array. Each has a different sensation, selected from the drop-down box of the Sensation Block field. The Running status remains false until one of the checkboxes in the running scene is clicked.

The game objects labelled RunningHapticA and RunningHapticB are Toggle checkbox objects and set the Running status of the referenced Sensation Source.

The RunForButton button has on OnClick method that calls a script function attached to the slider, which in turn calls the RunForDuration method of the referenced Sensation Source.

We can use the Running status directly or the RunForDuration method to play back our haptic on some event, such as a collision trigger.

With the RunForDuration method, sensation playback will continue in the background once triggered, allowing other UI events to happen. It also gives priority to the most recent call, so that any currently running sensation stops when RunForDuration is called by another sensation. You may wish to experiment with this by modifying the scene to add a second “Run for Duration” button associated with a different sensation.


Running and Enabled Properties

Each component of a Unity Game Object can be enabled or disabled. Either check or uncheck the box at the top left-hand corner of the component or set the enabled property in a C# script. Take a look at this video tutorial on Unity.

For a Sensation Source to be “playing”, its Enabled and Running checkboxes must be checked. These checkboxes have two distinct purposes:

  • Enabled checkbox: Enabling or disables the Sensation Source’s enabled This has the effect of starting/stopping time for the sensation. If disabled, then enabled, the sensation will start from its initial position, at time = 0.
  • Running checkbox: If we start and stop using the Running property, the sensation’s time state continues incrementing in the background.

The effect of these two checkboxes can be seen by toggling the enabled checkbox of Sensation B in the example scene. The dial sensation traces a circular path that always starts from the same position. In contrast, when toggling the Running checkbox, the dial sensation’s position is not reset – its time loop continues in the background.

The difference is important when dealing with haptics that evolve over time, such as an expanding circle sensation. Both enabled and Running properties must be set for haptics to be played.


Haptic Priority

Your Unity scene may require several Sensation Sources to be triggered or disabled, depending on your application. For example, a space shooter game may have one haptic sensation associated with the controllable space ship, but different haptics for firing a weapon or being hit by asteroids.

The Priority value allows you to decide what haptic should happen when. Higher priority haptics will play, even if lower priority ones are running. Lower priority haptics is disabled by higher priority ones. This is demonstrated in the UCA’s Priority example scene.

This has a hand tracked ‘cursor’, a “scanning”, blue line and a bouncing, orange ball. The green cursor has the lowest priority (1), while the blue line has the highest (3). You can see the active sensations in the Sensation Emitter component of the Ultrahaptics Kit game object.



The Priority scene requires the Leap Motion® prefabs to be added. You can read instructions for adding the Leap Motion to your Unity scene in the next lesson or the Quick Start Guide.

Next tutorial: Triggering Sensations with Hands

Have more questions? Submit a request


Article is closed for comments.