O'Reilly logo

Unity Game Development Scripting by Kyle D'Aoust

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Sound effects

To play sound effects within our game, we will make an event-based system so that playing the sound effects will be very easy. Sound effects are what bring your items, events, and characters to life! They give your gun the loud bang you would expect, the grunt from your character as they climb a wall, and the notification sound that you get when you hover over an option in the menu. Sound effects add to the immersion of your game and playing them can be very easy.

Creating the script and variables

Our first step in playing sound effects will be to create the C# script and name it SFX_Manager. Next, we will need a few variables; add these to your script:

public float sfxVolume = 1.00f; public AudioClip Run, Spell, Strike; public GameObject ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required