How to Play Sound Effects in Unity

Beep Boop Buup? Wait, what is that? Sound effect? Yes! How to play a single sound effect? Here’s the “secret”

Photo by note thanun on Unsplash

Play a sound effect when you shoot a laser

When we start we need an AudioClip where we store the audio clip we want to play. And a private AudioSource.

And then we need a code that plays that clip when we want :)

Then we null check the Audio Source. If it’s empty, we Debug.Log that it’s empty and if it’s not empty, we play the clip.

And now when we want to play that audio clip. All we need to call is

Thank you for reading and I hope this helped!
Feel free to comment or contact me if you have any questions! :)



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
Janika Suhonen

Janika Suhonen

From the beautiful snowy country with a touch of "good" humor? Inspired Unity Developer to learn more.