Game Development Reference
In-Depth Information
Atmospheric sounds
Now, we will create a system to handle atmospheric sounds. Atmospheric sounds are
sound effects played in a game to give your scene more immersion. Some good ex-
amples are wind blowing in a field, the sounds of drowned out chatter in a pub, your
character breathing hard after running for a while, and so on.
Creating the script and variables
To start off, we will need to create a new script and name it ATM_Manager . Next, we
will create a few variables needed to play our sounds:
public List<AudioClip> tmpList = new
List<AudioClip>();
public List<string> keys = new List<string>();
public List<KeyValuePair<string, AudioClip>>
atmList = new List<KeyValuePair<string,
AudioClip>>();
public float atmVolume = 1.00f;
The first three variables that we create are lists. The first of our lists is an AudioClip
list, which will hold the sound files that we will use. Next, we create a string list, which
we will fill with the name of the sound file that we want to call within our code. The
last list is a KeyValuePair list, which will put together the strings and AudioClip
variables we just created, and put them in a list that we will call within our code. The
last variable we create will be for the volume of the sounds.
Initializing the variables
To give a value to our list that we will use within the code, we will create a Start
function that initializes the list. Add this to your Start function:
void Start()
{
audio.volume = atmVolume;
Search WWH ::




Custom Search