Making a RTS game #17: Introducing a sound system 2/2 (Unity/C#)

Let’s keep working on our sound system for our RTS game — time to really code it up!

Mina Pêcheux
CodeX
Published in
12 min readJul 1, 2021

--

⬅️ Tutorial #16: Introducing a sound system 1/2| TOC | Tutorial #18: Preparing our game parameters ➡️

📕 Get the ebook and bonus material on Gumroad!
🚀 Find the code of this tutorial series on my Github!

Last time, we talked about the importance of sounds in video games and how they increase the immersion of the player; we also took a look at Unity’s sound system and even “pre-optimised” our sound file imports to avoid consuming too much memory. In this second part, we’ll focus on how to actually implement the sound system. So we’re going to see how to play some background music, global and local ambient sounds and contextual sounds like unit responses.

Note: I’ve embedded some videos with sound in this article to show our progress as we code the feature, but the quality of the sound recording isn’t very high — sorry in advance!

Preliminary step: moving the listener to a “ground target”

In part one of this duo of episodes, I mentioned that we had to tinker with the default listener setup a bit. Unity…

--

--

Mina Pêcheux
CodeX
Writer for

I’m a freelance full-stack web & game developer. I’m passionate about topics like CGI, music, data science and more! Find me at: https://minapecheux.com :)