Audio Feedback
Tutorial
·
Beginner
·
+10XP
·
10 mins
·
Unity Technologies

Add sound effects and audio feedback to your experience.
Languages available:
1. Add sound to an animation
Let’s add sounds to the scene. The first sound we are going to set is the one for the wind turbine. As we already have the interaction launching the rotation of the propeller we are simply going to add an ‘Audio’ action to it.
Select the Propeller(IO) inside the Activity 3. Select the TurbineRotates interaction. Go to the ADD ACTION list and add the Audio one:

Add Audio action
Under Audio Clip drag the Turbine.mp3 sound provided with the tutorial:
Turbine sound
Check the Loop option for the sound to loop. We recommend you lower the volume not to annoy the user and also to make it seem further away.
Repeat this step inside the ShuttleLaunch interaction and use the ShuttleLaunch.mp3 sound:
Shuttle sound
Press play and check how both audio clips play; adjust volumes if necessary.
2. Audio feedback
Audio is also an effective way of giving feedback to the user when something has happened. Let’s add a sound effect when the red brick has been properly snapped to its target.
Expand again Activity2, go inside the RedBrick(IO) and duplicate the Empty interaction; rename it ‘RedBrickDropped’ for example.
We need to know when the brick has been dropped, for this we use the ‘Drop’ condition from the ADD CONDITION list.
Set the object and the target like this:
Drop condition
Then add the ‘Audio’ action and use the BrickDrop.mp3 file:
Brick audio feedback
3. Repeating a sound effect
To also give feedback we are going to add a sound when the user waters the flower. However we want this sound to play every time the user does this gesture even if the flower only grows once.
This means we are going to play the audio in a separate interaction from the one of the flower. Go inside the Watercan(IO) and create an interaction called ‘WaterAudio’ for example. The condition is the same as the one from the flower growing. To avoid setting the condition again, you can go to the FlowerGrows interaction and copy the values of the component, then go to the interaction inside the watercan and paste the component as new, to add the condition already set:

Copy-Paste a component
Then add the ‘Audio’ action and set it with the Water_1.mp3 sound provided. To make the sound repeat every time we need to actually repeat the interaction itself. For this go in the Inspector, under Interaction Setup and check the ‘Repeat’ option:
Repeat an interaction
Set it to repeat Infinite times and to check only the conditions. We recommend adding a delay between each iteration so the sound does not overlap.
Press play and test the interaction. Adjust the delay value if necessary.