Game Development Reference
In-Depth Information
Sound Listener and Sound Source Paradigm
Unity works with a fairly straightforward metaphor for sound—namely,
one object contains or emits the sound, and another object hears it. Strictly
speaking, an Audio Source (emits the sound) is a component of a GameObject
placed in the scene. This means any object (ticking bomb, dripping pipe, etc.)
can have an Audio Source component and thus can be the source of audio.
However, an empty GameObject can also be created with the express purpose
of emitting sound from a certain locale.
Similarly, the Audio Listener is also a component of a GameObject in the
scene. Cameras automatically include the Audio Listener component. So our
First Person Controller's Main Camera is always listening for any Audio Sources
in the scene and then plays that sound through the player's speakers. Because
this is already in effect (you can take a look at it in the Inspector when Main
Camera is selected), and because the Audio Listener really has few options,
our main focus will be on creating and adjusting our Audio Sources.
Tutorial 11.1: Placing Sound in Unity
As discussed earlier, Audio Source components can be added to any
GameObject; however, I prefer to always assign static (as in not moving around
within the scene) Audio Sources to GameObject specifically created to house
them. It just allows for a much quicker understanding of the scene when I can
see the Audio Sources in the Hierarchy as opposed to searching them out if they
are attached to other GameObjects. This tutorial is built up on this preference.
Step 1: Be sure that the audio clips have been imported in Unity. In
the Project panel, choose Create>Folder. Name the new folder Sounds
and make sure all the sounds downloaded and assembled reside here.
Alternately, this organization could have been done previous to placing
the assets into the Unity project folder and simply placing the entire
Sounds folder within it.
Why?
Unity is pretty friendly when it comes to sounds. Among the sounds
included in my project is an .aif, .wav, and .mp3; and all came in without
so much as a complaint from Unity. It's one of the real benefits of Unity's
open arms approach.
Tips and Tricks
If an audio clip is selected in the Project panel, the Inspector will show
that clip. Of particular use is the Preview pane that will appear at the
bottom of the Inspector. Here you can take a quick listen to any sound
clip that is part of the Unity project.
Search WWH ::




Custom Search