Making my game more immersive with sound

Matthew Bartosh
2 min readAug 13, 2022

Today my goal is to add sound to my game! I’m going to start with background music.

The first step is to add an Audio Manager object, beneath it I’ll place another empty GameObject named Background. On this Object I’ll stick an Audio Source component which will allow me to source and play audio. No scripting needed for this one, just select my background music and set it to Play On Awake and Loop.

Now that that’s taken care of, I need to start looking at adding the rest of the sound effects. I have a laser sound, an explosion, and a sound for when powerups are picked up.

I’m going to start with the laser, as that’s probably the simplest one. First I’m going to reference the AudioClip and the AudioSource in Player.cs, then GetComponent for the Source.

Next I’ll just _audioSource.PlayOneShot(_laserShot); after the laser is fired, and that’s it!

I’ve got the laser set up, so I’ll talk about the other sounds next time, including why I’m choosing to use PlayOneShot for the laser.

--

--