11 Playing audio: sound effects and music

This chapter covers

  • Importing and playing audio clips for various sound effects
  • Using 2D sounds for the UI and 3D sounds in the scene
  • Modulating the volume of all sounds when they play
  • Playing background music while the game is being played
  • Fading in and out between different background tunes

Although graphics get most of the attention when it comes to content in video games, audio is crucial, too. Most games play background music and have sound effects. Accordingly, Unity has audio functionality so that you can put sound effects and music into your games. Unity can import and play a variety of audio file formats, adjust the volume of sounds, and even handle sounds playing from a specific position ...

Get Unity in Action, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.