Justin Hur
Game Programmer
Documentation
Objective:
The task is to redo how the audio is set up. Basically, the audio is attached to the gameobject the sound correlates too and managing all the audios at once is a bit of a hassle. So I'll be working on trying to get the sounds that we have under one gameobject and have it so that it's able to adjust volumes or pitches more easily that just going through each and every audio source.
​
Process:
To start off I made a AudioManager gameobject, and then a child gameobject that contains all the Audio Sources for the clips that we are using for the game. The reason I kept all the audio sources together in one gameobject is so that everything is together and I dont have to search for where each audio source is. I then created a script called AudioManager.
Before doing anything in the AudioManager class, I made more classes for the different audio types that we have. This is keep some organization for when the Inspector gets edited later. In those classes, I had a public AudioSource, public string Name (audio file name), public float Pitch (ranging for 0 to 1), and a public float Volume (ranging from 0 to 1). The purpose for the pitch range is so that we can adjust the pitch necessary for when the player slows down time. The volume range is more so we can adjust the volumes as we play the game so that all sounds meld together nicely when playing the game.
​
In the AudioManager class, I made an array of every audio type class, then a list of AudioSources and then a list every pitch value. The list of AudioSources is for when the player wants to change the volume or pitch in runtime. The list of pitch values if for when time is reverted to normal, so does the pitch.
​
In the update method, there is an if statement that checks whether or not the player presses the time slow button, if true, then the method SlowDownPitch is executed and all sounds in the list of audiosources is then changed to 0.5f. Once the if statement is false, then the RevertPitch method runs and all the sounds revert back to their previous pitch values.
​
In a another script called AudioManagerEditor. I changed the inheritance from Monobehavior to Editor. This allows the inspector of the AudioManager script to be changed. Then I used the OnInspectorGUI method to have the original inspector of AudioManager, but also added a button that runs the AdjustFromInspector method in AudioManager to change the volume or pitch value.
​
To play the audio clip, there is a method called PlaySound that takes the name of the clip to be played and a bool if it's a clip that should be played once. The bool is mainly for if a clip should be looped, like music. A instance is also made so that any script can easily access this method to play sounds. From there, I summoned that method from the scripts that needed to play a sound.