Unity3D : Environment Ambient and Spatial Sound
This tutorial assumes you have carried out the tutorial on creating and texturing a basic terrain: Unity 3D: Creating and Editing a Terrain.
This activity will show you how to add sound to an environment; an ambient sound that is heard at the same volume throughout the environment and a 3D sound that can be attached to a GameObject to provide spatial sound to be used as a sonic beacon.
1. Load a Unity 3D project from a previous tutorial.
2. Download the two audio clips from the module homepage ambience.aif and beacon.mp3 Import both files as new assets.
3. Select the ambience.aiff audio clip in the Project window drag and drop the ambience.aiff audio clip from the Project window into the Scene view. The Inspector view should now show the new Audio Source component. Make sure Play On Awake is checked and Loop is checked. Run the scenario, you should now hear an ambient sound effect that is heard throughout the environment.
4. Create a Cube GameObject and name it SonicBeacon. Drag and drop the beacon.aiff audio clip onto the SonicBeacon in the Hierarchy window. Select the SonicBeacon in the Hierarchy window and in the Inspector window adjust the Spatial Blend to about 0.9 The Spatial Blend controls the 3D aspect of a sound. The lower the value the less 3D the sound becomes. Also, as the audio clip is attached to the cube wherever the cube is placed the audio will emanate from the same position.
5. Position the SonicBeacon in the environment away from the initial position of the FirstPersonController GameObject and run the scenario. You should hear an ambience sound and a directional sound emanating from the SonicBeacon. Try to find the beacon’s location by using the spatial sound source as a guide.