Unity Dev Blog: Immersion Starts With Sound

Make sure you have your sound turned up for this article…

Good games have several things in common; they have great game play that feels effortless and fun, they have graphics that help draw you in, and they have sound (background music, ambient sounds, and sound effects) to increase the level of immersion.

If you have quality audio assets at your disposal then Unity makes adding background music and sounds to your game as simple as adding an Audio Source component and linking a reference to the audio files. For example, here is how I added the background music.

  • I added an empty game object the the Game scene and named it Audio Manager to handle all of the audio in the game.
  • Inside of this empty game object I added another empty game object to hold (and play) nothing but the background music and named it BackgroundMusic.
  • I added the Audio Source component to this empty game object and dropped a reference to the background music audio file.
  • Finally, I adjusted the Audio Source component setting to have the audio file Play On Awake and to Loop.

Nothing too overly complicated! Now, as soon as the game starts, the background music starts to play and will play over and over until turned off or the user exits the game.

Here is how it sounds (make sure to turn your volume way up!)

I hope you did not fall for that gag. There is sound in the game but not in the gif above. :-) Keep an eye out for the finished version to be posted online at http://mrmikeonebike.com for you to play so you can hear the sounds for yourself.

Yeah, I know, that was a dirty trick, but admit it…it was a little funny right?

But seriously, adding in sounds, especially background music that just plays while the game is running is just that easy!

This was a short article dealing solely with playing a very simple audio file for background music. In the next article I will show you have to add sound effects to the explosions, laser fire, and power-up pick up.

See you there!

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Michael Hatfield

Michael Hatfield

46 Followers

Math and science teacher / self-taught programmer and Unity game developer working hard to get into the game development industry fulltime.