Unity

UCA Tutorial #7: Sensation Animation and Sequencing

450 views 19/02/2019 Nicci 0

Previous tutorial: Hand Tracking Helper Functions

Next tutorial: The Forcefield Sensation

Introduction

In this tutorial, we look at the Sensation Animation and Sensation Sequencing examples and how we can use Unity’s timeline editor with sensation parameters and playback. The timeline is a cool editor that allows us to get at some sub-components that are difficult to control through the basic animation method. With the Sensation Sequencing example, we trigger the playback of two different sensations. In the Sensation Animation case, we control the CircleSensation’s radius property.

Tutorial 7 circle Sensation

As an introduction to the Unity Timeline, here’s a great video that you may find quick and helpful.

Scene overview

The Sensation Animation scene is already preconstructed with a CircleSensation playing back 20 cm above the array with a varying radius. Open the scene and play it to understand what’s happening.

You should be able to see that the Circle game object contains the Sensation Source component and a CircleSensation. It also has a script called SensationAnimationExample.cs (displayed as “Sensation Source Animation Example”). This exposes the public variable AnimatedRadius, which updates the CircleSensation’s radius input on each frame.

Animate your object

Create a new scene, adding your UltrahapticsKit prefab and add a Sensation Source with a Circle sensation and the SensationSourceAnimationExample.cs script.

To animate this, create an Empty Game Object (name it something like “AnimationTimeline”) and open a “Timeline” window in the editor (click Window->Timelinefrom the menu). Select your AnimationTimeline object and click the “Create” button. This will generate a playable Timeline asset in the project pane and a Playable Director component on the object.

An Animator is needed on the object being animated, i.e. the ‘Circle’, but not on the “AnimationTimeline” we’ve just created, so remove it. You’ll also need to delete the default, self-referenced track from the AnimationTimeline object you’ve created: select the track, right-click and delete.

Right-click in the Timeline window pane to create a new Animation track and drag the object you wish to animate into this assignment slot, in this case, the Circle object. If your Circle object does not have an Animator component, you’ll be prompted to create one. Now we have an animation set up, but no real data…

  • Click the track’s small, red record button to begin the process,
  • Navigate to the Circle object and select the “Animated Radius” variable of the “Sensation Source Animation Example” component and change it. This will create a keyframe with the proper variable to edit.
  • Continue to add keyframes by moving the cursor to different points along the timeline and changing the Animated Radius.

Tutorial 7

  • You can now click the record button again to exit this mode. Double-click the track or right-click the track’s menu icon to open the Animation window with this animation ready to edit.

You can edit the animation using keyframes or the curves option per normal. This animation will be tied to the Timeline object you have created, generating an animation file alongside your scene.

One more tip worth noting is that you can change the animations behaviour to continuously loop by selecting “Loop” from the Wrap Mode drop-down box. Now you can create pulses, button clicks, rumbles or whatever you wish…

Sensation Sequencing

This scene shows how to use the same editor as above (Timeline) but instead of animation tracks, we use “Activation” tracks to turn game objects off and on. Here, we’ve simply created two sensation objects and dragged them to our two activation tracks. We create active clips by right-clicking on the menu and dragging it to the position we want. We can change the length by directly setting its duration or by dragging the length of the clip.

Tutorial 7

Now when you play the scene you should be able to feel the distinctive SOS Morse code tapping out in mid-air.

Next tutorial: The Forcefield Sensation

Was this helpful?