How to Play Sound Effects in Unity

Objective: Play a sound clip with a C# script

Bradley Yachimowski
2 min readJun 6, 2021

Create an “Empty Game Object” and call it “Audio_Manager”. Use Add Component” to add the “Audio Source” component. Create a C# script and name it “ Play Laser Sound”. Add the C# script to the “Audio Manager” game object (“Drag and Drop” on to the “Audio_Manager”).

Open the “ Play Laser Sound” C# script and create a private Serialized Field variable of type AudioClip and call it “_laserSoundClip”.

Create a second private variable of type “AudioSource” and call it “_audioSource

This creates a slot (Laser Sound Clip) in the Inspector where we will “Drag and Drop” our sound clip.

Make sure the “Play on Awake” and “Loop” boxes are unchecked in the “Audio Source” component.

Now let's add the code required to play our laser sound.

When we start our game “void Start” function will make a call to PlayLaserSoundClip() and we will hear the laser sound one time. That’s all there is to play a sound clip from within a C# script…Until next time…

--

--