Game Development Reference
In-Depth Information
this sound. Game objects inside Unity can have a
Component known as a Collider attached to them. In fact
for most simple objects that can be created by the Game
Object menu this Component is already automatically
added to them.
Let's take a look at the Door object. Search for this object
in the Hierarchy, and click on it to review the inspector
view for it. Look for the Box Collider component attached
to the object. Now, i nd the Is Trigger option and click on
it to enable the trigger functionality.
Add an Audio Source to this via Add Component
Button >Audio>Audio Source .
In the Audio Source leave the AudioClip i eld blank
and turn of Play On Awake and Loop if they're not
already of . You might wonder how we're going to hear
a sound now, since the Clip i eld is blank. The answer
is that an Audio Source can just be a source of audio
for a group of AudioClips. In fact you could trigger
dozens of AudioClips to play through a single Audio
Source. The signii cant limitation here is that it cannot
adjust volume independently for all those i les playing
through them.
Setting Up A Script
OK, we have now reached the end of what's possible
inside Unity without having to learn some code to go
further. Fortunately it's not really hard
to do these next steps.
1. Create a script in the Project View by clicking and holding the Create
button and selecting Javascript.
 
Search WWH ::




Custom Search