Devlog 2 - Audio Implementation


The past few weeks, I've been working on a few things related to audio. I found some pretty neat SFX from freesound.org and Soniss' free GDC audio bundle archive (shout out to them for making hundreds of SFX available for all to use!).

I also tried my hand at making a tune for our first minigame, themed around the arcade basketball game. I used Bandlab for its simplicity and accessibility. It's browser-based, so I was able to work on it anywhere if needed. With only my ears, I just started playing notes on the virtual keyboard until I found a progression I was somewhat happy with.

The top (orange) section is the drums, while the middle 3 (purple) sections are just different instruments playing the same tune layered over one another. The bottom (blue) line is a C major chord being played by a bass, which is the key that the entire melody is built on.

Here's a clip of what it sounds like so far.

I'm not a fan of how much it loops and the bassline sounds wrong, but I'll be working on fixing those in the coming weeks. Unfortunately it wasn't able to make it into the playtest either, which is a bit of a bummer, but not too bad for my first time!


What was able to make it into the playtest build was some of the SFX. I was planning on creating an AudioManager script and using a singleton for global accessibility. My professor suggested a different method - Unity Events. I'd only learned about C# events previously, but they work pretty similarly; the biggest pro is that they can be serialized, meaning that the events can be set up in the editor

Using a combination of code like this:

public void PlaySFX(Audioclip clip) <- Function to be called
public UnityEvent<Audioclip> OnThrow; <- UnityEvent that can be seen in editor
OnThrow?.Invoke(null); <- Calling the UnityEvent, 'null' is so I can place my own Audioclip in editor


This is what it looks like in the editor - Essentially, when the throw function is called, the event fires and calls the PlaySFX function with the associated audio clip (placed in editor, rather than code)! Much easier than having to save an audio clip as a variable in the throw script. It seems more convoluted to set up (i.e. in script and editor) than simply having an AudioManager that can be accessed globally but I think that this is an extremely good tool for larger games.

Get My Ordinary AR Life