Watching:

How to Use an audio source Unity 4.3


show more Using an audio source provides you with in-depth training on 3D + Animation. Taught by Adam Crespi as part of the Unity 4.3 Essential Training show less
please wait ...

Using an audio source

Audio is in many ways as big of a part of the game as the visual components. We expect to hear things with every thing we do. And we expect to hear situational audio as we move around from place to place in a game. The different kinds of audio we'll hear in a game then are positional, or 3D. Where we move into a defined zone and the sound increases or decreases depending on distance. We'll also hear audio that's continuous. Things like backing music for an example. Finally, there's triggered audio. Audio that goes with a particular animation, such as a door opening or lock turning.

I put some sound files in the Assets folder. And I'll get them organized in their own Sound folder. And then look at how sounds come in and what we can do with them. I'll start out by making a new folder in the assets. Right-clicking and choosing Create and Folder. I've named this new folder Sounds. And I'll pick all of these sound files and move them into that Sounds folder. When audio comes in, we have options as to what to do with it. I'll select the interior tone for an example. We can see that it comes in natively as a wave, and we have a choice in here in the audio format to compress it to the AugVorbis or leave it alone.

Often we want to have positional, or 3D sounds, stay Native. Whereas long tone sounds may work better compressed. It's up to you how you'd like to run it, and it also depends on the platform you're authoring for. Different mobile platforms may have different ways of dealing with the audio and compressing it accordingly. I'll leave this Native, as it's already fairly small. This is my interior room tone and it's a 3D sound, meaning that I can make it positional and in a radius. We also could decide to load it into memory, or to stream it from a disk, if we're actually working from a disk.

I'll preview this audio. It's about 1:30 minute worth of a deep bass and room tone. It's basically a room tone to fill the space, plus a hum from the ventilation. We can tone it back, but it'll keep our interiors from being entirely quiet, while still reinforcing the stillness of our gallery. Here's a lake tone with birds. This is the one that we're going to use occasionally when we step out onto the balcony. And again, I'll leave it Native for now. It's the sound of water on a lake. Fairly still, but it still has some ambient water sound and occasionally, there's a bird or other noise in there.

When we're dealing especially with an outdoor environment, we can think of the sound as a way to fill up that forest or jungle, for example. A lot of times, there's a lot of things we hear and we really never get to see, like birds or maybe other animals in the trees. We need to hear that there's some life out there in addition to the water, and there's a wind tone as well. And all of that together reinforces the idea of this being a very live place around us. In realty, there's actually no birds in the scene, it's just the audio getting the idea across.

Finally, here's the door open. This is the one I've clipped down and really scaled back. So it's a very, very slight sound that will play when we trigger the door. It's just enough to show that that door is opening. And we'll get it to sync up. And it will reenforce that something is going on here that the player has triggered. In Unity then, there's an audio listener component, and it's attached by default to the first person controller and main camera. If you've seen a note down at the bottom of the screen occasionally, saying there can only be one audio listener in the scene, here's what it means.

On the first person controller, in that main camera object, there's an audio listener. And also on the main camera that's created by default in our scene, there's an audio listener. The audio listener doesn't have any properties. What it does is listen to what's going on and actually determines what we hear through our speakers or headphones. I'm going to take the AudioListener off my main camera, leaving it just on the first person controller. Now, I've got exactly one Audio Listener here. And I'm ready to listen to the sounds I'm adding in.

Using an audio source
Video duration: 4m 3s 6h 49m Beginner

Viewers:

Using an audio source provides you with in-depth training on 3D + Animation. Taught by Adam Crespi as part of the Unity 4.3 Essential Training

Subjects:
3D + Animation Developer
Software:
Unity
Author:
please wait ...