3 Create Actions and Control Volume with a Variable
Before you start: Confirm that Explorer → Assets → Layer → Gameplay contains the SFX_Ball_Roll_Loop Sound and the SFX_Ball_Pickup container.

Create Three Actions#
An Action is an entry point you can execute: a Play Action starts a sound, and a Stop Action stops it. Sounds and Containers still define the audio content and playback rules. Unity will use these three Actions to control the game audio.
In the Explorer, right-click the
SFX_Ball_Roll_LoopSound and choose New Action → Play.
Right-click the same
SFX_Ball_Roll_LoopSound again, this time choosing New Action → Stop.
Under Action in the Explorer, confirm that
Play_SFX_Ball_Roll_LoopandStop_SFX_Ball_Roll_Loopappear.
Return to Layer → Gameplay, right-click the
SFX_Ball_Pickupcontainer, and choose New Action → Play.
Under Action, confirm that the third object is named
Play_SFX_Ball_Pickup. This Action plays the Random container configured in the previous chapter.
Audition the Three Actions Individually#
In Explorer → Action, select
Play_SFX_Ball_Roll_Loopand press Space. You should hear the loop start.
While the loop is still playing, select
Stop_SFX_Ball_Roll_Loopand press Space to execute this Stop Action. Confirm that the loop stops.
Select
Play_SFX_Ball_Pickupand press Space. Wait for the sound to finish, then trigger it a few more times to audition the random variations. Each trigger should play only one sound.
Press Ctrl+S to save the project.
Create BallSpeed to Control Volume with a Variable#
As the ball accelerates, its rolling sound should become louder. The audio system first needs to know how fast the ball is moving before it can determine how loud the sound should be. A Variable is a project object that passes values of this kind. Name this one BallSpeed.
Think of BallSpeed as a speed knob that the sound's playback rules can read. This tutorial maps speed to 0–1: 0 means stopped, 1 means the speed chosen for full volume, and 0.5 means half that speed. These values are neither actual speed units nor volume percentages.
The variable supplies the input; the binding curve determines how that input affects volume. You will bind BallSpeed to the Volume of SFX_Ball_Roll_Loop: an input of 0 corresponds to −24 dB, an input of 1 to 0 dB, and intermediate values are calculated from the curve.
In this chapter, adjust this knob manually in Studio's Control panel and listen to the volume changes. After connecting Unity in Chapter 7, the script will read the ball's speed and update BallSpeed. Naming a variable BallSpeed does not make it detect the ball's speed automatically; the two Actions created earlier still start and stop the loop.
Create and Configure the Variable#
Find Variable under Explorer → Assets on the left of the main window.

Right-click Variable and choose Create → Variable → Smooth.
Why choose Smooth? The ball's speed is not limited to stopped and moving; it also passes through intermediate speeds. Smooth accepts continuous values such as 0.1, 0.25, and 0.5, making it suitable for controlling volume with speed. Step is better for categories represented by discrete values, such as 0 and 1 for two ground materials.

Name the new variable
BallSpeed.
Select
BallSpeedand find Range under Inspector → Basic → Identity on the right. The right-hand field currently shows 100; change it to1. Range defines the variable's allowed values: in this exercise, the minimum is 0 and the maximum is 1.

Find Default Value below and change it from
0to1. Default Value is the value used when the variable is initialized.

Bind BallSpeed to the Sound's Volume#
Return to Explorer → Layer → Gameplay and select
SFX_Ball_Roll_Loop.
Find Volume under Inspector → Basic → Playback on the right. Click the binding button at the right end of the Volume row, then choose Select Variable from the menu.

Find
BallSpeedin the Variable selection window and double-click it to open the External Editor.

Set the Volume Curve from −24 dB to 0 dB#
The horizontal axis represents the BallSpeed input over a range of
0–1; the vertical axis represents the Volume gain adjustment in dB. In the External Editor curve graph, move the pointer onto the small circular point at the far left, then right-click and choose Enter Coordinates....
In the coordinate fields that appear, leave X at
0, enter−24for Y, and press Enter.

Move the pointer onto the small circular point at the far right, then right-click and choose Enter Coordinates....

In the coordinate fields that appear, leave X at
1, enter0for Y, and press Enter.

Confirm that the curve connects
(0, −24 dB)on the left to(1, 0 dB)on the right. Only change the two existing endpoints; you do not need to add control points.Click the close button at the upper right of the External Editor window to return to the Studio main window.

Change the Variable in Control and Audition#
In Explorer → Action in the main window, select
Play_SFX_Ball_Roll_Loop.
If the Control panel is not visible at the bottom of the main window, click the middle of the three panel icons at the upper right.

Alternatively, choose View → Control at the top of the main window. Either method opens the panel.

Control appears at the bottom of the window. If the panel is too short, move the pointer to its upper edge, hold the left mouse button, and drag upward until the variable row is fully visible.

Confirm that the Control title shows
Play_SFX_Ball_Roll_Loopand thatBallSpeedappears on the left. Return to the Explorer, select this Action, and press Space to start the loop.

While the loop plays, slowly drag the BallSpeed → Value slider on the left of Control and compare the volume at different values. Dragging left makes the sound quieter; dragging right makes it louder. At the far left, the volume is at its minimum.

Value on the left is the variable input; Value in the property table on the right is the corresponding Volume value. An input of
0should show−24 dBon the right; an input of1corresponds to0 dB.

When you finish comparing, set the BallSpeed input on the left back to
1. Then click the red square Stop button at the top of the main window to stop audition playback.

Press Ctrl+S to save the project.
Chapter check: You have auditioned all three Actions. BallSpeed has a range of 0–1 and a Default Value of 1. The Volume curve runs from (0, −24 dB) to (1, 0 dB). The Control input is back at 1, playback is stopped, and the project is saved. Continue to Chapter 4: Install Unity and Prepare the Roll-a-Ball Project.