I added some audio to my game EGONE and would like to talk about what it was for, how I went about making it and how I got it into my game.

The new audio is for when the player character and when they die in game or reach the end zone. Before, there wasn’t really anything that happened if when your character died or you completed a level other than a screen telling you which of the 2 outcomes you ended up getting. I thought this was a bit lame so I wanted to add a couple of sounds in to make it a little less… boring I guess.

I used Audacity to create the sounds that I would be using for my game. I made 4 separate sounds for when the player would loose and 3 other sounds for when the player would win. These noises were all me just making noises with my mouth into my microphone. These noises were labeled FailNoise01 – 04 and WinNoise01 – 03. The fail noises were comprised of 2 different variations of fart noises and 2 variations of noises I thought a person would make if they were in pain. The win noises were more speech based with words like “ah ha!” And “Piece of cake!”. Typical things one would say when taking a victory.

Using Audacity to create these noises were easy. All you really need is a PC and a decent mic. Recording a new sound and cutting it to size is easy and I won’t go into that here. Where some people may not have looked to go though is into the edit menu. In the edit menu is 2 tools that I used to help create my audio files for my game. The ‘Noise Removal’ and the ‘normalize’ tools. Using these tools bring up the quality of your audio and help keep noise levels in check. The Noise Removal tool is something that everyone should know how to use if they are going to be editing audio. This tool helps remove any unwanted background noise that you don’t want. It does this by first getting a sample of your background noise (you have to give it this so it knows what you are talking about) and then going over any desired part of your audio and removing similar sounds/imprints (You also tell it what parts you want the background audio to be removed from as well). To help get this background audio, it is a good idea when recording to leave a sort of dead zone before you start making noise so that you have a big area of nothing but background noise that you can give the editor as an example. The Normalize tool is a tool that I have been using to help remove any DC offset my audio clips may have(this really wasn’t needed for the level of audio I am going for but it’s something that I did). After the editing was done I exported the files and began trying to put them into my game.


This is an example of the DeadZone you use.

To put them to work in my game, all I did was create 2 arrays in the hit detection script for both sets of audio (win noises and fail noises: WinSounds, failSounds). With these being public, I filled them in the unity editor with the new sounds. I then created a set of new functions called PlayRandomFailSound and PlayRandomWinSound. These scrips are very much the same as they do the same thing but are grabbing from separate arrays. This script (Line by line) first generates a random number, creates an audio source on the object, uses the random number to select a clip and store it into the new audio source, plays the random sound and then destroys the audio source to keep things clean and tidy.

 public void PlayRandomWinSound()
 // Random Selected Number
 int randomClip = Random.Range(0, winSounds.Length);
 AudioSource source = gameObject.AddComponent<AudioSource>();
 source.clip = winSounds[randomClip];
 Destroy(source, winSounds[randomClip].length);

This is the code that to generate the random win noise for the game and is currently called in the same function that is called when the player wins/completes a level. This code is the same for when the player dies but rather getting an audio clips from the winSounds array it looks through the failSounds array.



Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s