7 Add Components and the Audio Script
Before you start: Complete the Pack export in Chapter 6, then return to the Unity project.
Add Two Components from the Unity Integration Package#
After installing the Unity Integration Package, you can find HarkenAudioSystem and HarkenListener through Unity's Add Component search. You do not need to download their scripts separately. In the Hierarchy window at the upper left of the Unity main interface, select Player under the Roll-a-ball scene.

Find the Inspector on the right and scroll to the bottom to locate Add Component. Click it and search for
HarkenAudioSystem. Click Harken Audio System in the results to add it to the Inspector. This component starts the Harken audio runtime, loads the Packs configured earlier, and provides a common entry point for the audio script you will add later.

Return to the Hierarchy window at the upper left and select Main Camera.

In the same way, search for
HarkenListenerthrough Inspector → Add Component on the right. Click Harken Listener in the results to add it to the Inspector.

In Harken Listener, click the circle button at the far right of Runtime. On the Scene tab, double-click Player. Runtime should then display Player (Harken Audio System).



Import the Provided Script and Fill In the Names#
After confirming that the Unity Integration Package is installed, both paths are configured, and the Packs have been exported, import the script below.
Click the following link to download it.
In the Project window at the bottom of the Unity main interface, find
Assets/UnityTechnologies/RollABall/Scripts.
Drag the downloaded
HarkenBallAudio.csinto this folder.
Return to the Hierarchy window above, select Player (the ball) under the Roll-a-ball scene, and add HarkenBallAudio through Add Component.



In the newly added Harken Ball Audio component, the three Action names and one Variable name are initially blank. Fill them in using the objects created in Chapter 3. The left column shows the Inspector labels, with script field names in parentheses. Copy the complete strings from the value column without backticks or quotation marks. If you reuse an existing component, old serialized values may remain; check each field against the table.
These four names must exactly match the corresponding Action and Variable object names in Studio, including capitalization, underscores, and spaces. Even changing a single letter's case may prevent the object from being found, so sounds may not trigger or the speed variable may not update. For example,
BallSpeedmust not be entered asballspeed. If you rename an object in Studio, update its corresponding field in Unity too. Copy the actual object name rather than typing it manually.
Inspector Field | Value | Corresponding Object or Meaning |
|---|---|---|
Pickup Action ( |
| Action that plays the Random container |
Roll Start Action ( |
| Action that starts the rolling loop |
Roll Stop Action ( |
| Action that stops the same rolling Sound |
Speed Variable ( |
| The Smooth variable from Chapter 3 |
Full Volume Speed |
| Planar speed that maps to a variable input of 1, in Unity distance units per second |
Speed Smooth Time |
| Input smoothing time in seconds |
What this script does: It prepares and resolves the three Actions, creates an emitter that follows Player, calls the corresponding Action once when rolling starts or stops, continuously maps planar speed to the global BallSpeed variable, and calls the pickup Action when entering a Pick Up trigger. It does not handle movement, counting, or hiding pickups; the original PlayerController still does those jobs. The script does not initially contain your object names, so you must fill in the four name fields in the table.
How the two numeric settings affect the sound: A higher Full Volume Speed produces a lower BallSpeed for the same actual speed, so the ball must move faster to reach the curve's 0 dB endpoint; it does not change the ball's movement speed. A higher Speed Smooth Time makes gain follow acceleration and deceleration more slowly; it does not change the curve's shape. Keep 3 and 0.1 for the first check in the next chapter before comparing other values.
Open Window → General → Console from Unity's top menu, or click Console in the lower part of the main interface.


Next, click Play at the top of Unity and watch the Console output. When
HarkenBallAudio: ready.appears, audio initialization is complete.


You can click the stop button at the top now, but leave the Unity project open. The next chapter covers auditioning.

Chapter check: Player retains its movement script and has Harken Audio System and Harken Ball Audio. The camera Listener's Runtime references Player, and all four name fields are filled in.