Getting Immersive with Sound FX

Soundwave from transformers…see what I did here! >:\

Sound Plan

We have several places where we want to play sounds. Let’s see what sound clips we have first.

  1. Laser Sounds
  2. Explosion Sounds
  3. PowerUp Pickup Sounds

For the purpose of today’s article I’ll focus on the laser shot.

Assuming that you have your desired sound FX file chosen and imported into your assets folder in Unity.

On our Player in the hierarchy, select the player object and in the inspector. We’ll add an Audio Source component. Make sure to uncheck “Play On Awake”.

Then in our Player script we’ll create a variable for the AudioSource controller and a serialized field where we will drag our soundfile into from the asset folder to the inspector.

In our Player script in our start method we we’ll also check to make sure the Audio Source isn’t null.

Finally in our FireLaser() method we sinply call on the audioSource.play()

--

--

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