Hey everyone and welcome back to the “Microgame Platformer” series! Today I’ll show you how to make pickup sounds that are in a musical key and also how to play them sequentially when picking up the crystals that are scattered throughout the game.

Let’s get going!

Making The Pickup Sound

So, since the game has a kind of “cute-sy” aesthetic, I wanted to reflect that in the sound as well. Especially the pickup sounds, because you’re going to be hearing those a lot during a playthrough of this type of platformer game.

I wanted to give them some sort of satisfying bell sounds but I also wanted to play very specific notes because I wanted to match the pickup sounds to the key of the music, so I pulled up “Collision” in Ableton, which let’s you design sounds using physical modeling.

Messing around with the default settings I quickly got a sound I liked, but the most important setting was the “Pitch” setting under “Pitch Envelope” (Highlighted in yellow below). With that, whenever I pressed a key on my midi controller, say the note C, there would be a glide down or up (depending on your setting) to the played note. This kind of effect instantly makes a sound more fun and satisfying in some way.

I then added another layer of Collision without the pitch envelope, just to give it some more texture. Here’s how that looked;

Remember, in Ableton you can always group multiple instruments/VST’s to be able to play them at the same time! You can do this be clicking on an instrument/VST on a midi track, pressing CMD/CTRL + G to make a group, and then drag a whatever you want to play into the group. This is very useful for making complex synth sounds or very “rich” sounding content.

At the end I added a bit of “Raum” reverb from Native Instruments, which can do some weeeiiirddd stuff to your sound, worth checking out if you haven’t already!

Here’s how my pickup sounds ended up;

Now, go ahead and create your own pickup sounds and also try to get them to fit in a musical key (I chose C Major, for simplicity).

When exporting your pickup sounds, it’s extremely important that you name them so that you can easily put them in order (because we want to play them sequentially, remember?!).

So, just to explain my naming convention. It’s basically Type_Range+Note. So in this case, the type of sound is a “pickup” sound, the range could be Low (L), Middle (M) or High (H), and then the notes C, F or G.

I’ve only chosen the notes C, F and G, because I don’t want to run into too much trouble with the music we’ll be creating in the future.

Implementing The Pickup Logic

Hop into FMOD, create a new “SFX” folder and make a 2D event called “Pickups”. Inside of that event, make a Multi-Instrument and put your pickup sounds into that.

Order your pickup sounds from lowest to highest note (top to bottom), by manually dragging the sounds around in your Multi-Instrument.

Now, set the Multi-Instrument to “Sequential – Global Scope” by clicking on the drop down bar just above your sounds. This is what will make your play in sequence. Try pressing the play button to make sure the logic works.

Now we need to get the logic set up in Unity as well. So press one of the pickups and you’ll see that it already has a script called “Token Instance”, that is actually already referencing a sound. So, we probably want to put our FMOD logic in here as well, so open it up.

The script can look kind of confusion at first glance, but try to follow along here. The scripting is 99% the same as last time. Write your FMOD namespaces at the top of the script, just like we did last time.

Create the event instance variable just above the “Awake” method and call it “pickupSound”.

Inside of the “Awake” method, make sure you assign pickupSound to the correct sound.

Then inside of the “OnTriggerEnter2D” method, set the sound to play. The reason being, that every time that the player enters the trigger box of the pickup (which also deletes the pickup), we want it to play the sound.

Hop back to Unity and try playing the game. The sequential audio logic should work when you pick up the crystals, but there’s something wrong here, can you hear it?

Three times at the start and sometimes after that, the pickup sound will play, even though you haven’t picked up any of the crystals. Can you guess why??

The reason is that the enemies are also sometimes jumping over the pickups and therefore activating the trigger logic, which then plays the sound. So, we need to make sure that it only plays the sound whenever we, the player, enters the trigger.

For this we’ll use “tags”. Tags are basically Unity’s way of separating different gameobjects from each other, using names. So when clicked on your player (the picture below is from an enemy, sorry!), navigate over to the inspector, click the little dropdown next to where it says “tag” (under the name of the gameobject), and click “Add Tag”.

You can then click the little plus button (highlighted in yellow below) and make a new tag, call it “PlayerCharacter”. Hop on back to character, and make sure it uses this tag by selecting it from the dropdown menu.

The final step is to get this logic set up in the code, so we’ll use an “if statement” to check for the tag.

An “if statement” basically asks the question “if this = this, then do this!”. So, change the code the what you can see down below, where we basically ask if the tag is called “PlayerCharacter” and if it is… then play the sound.

And Voila! Everything should work as intended now! Hope you had fun following along this week, and as always feel free to contact me if you have any questions whatsoever!

See you next week! 🙂