Let’s Get Started!
Today we’re looking at basic audio randomization in Unreal Engine! I’ll guide you step by step, explaining everything you need to do. Lastly we’re going to have little discussion about how getting a grasp on using blueprints, actually helps you understand what’s going on in Wwise and FMOD better… Wait, what’s that?! Is that a sweet randomized sound I hear in the distance?? We better go check it out!
First Things First…
I’ll be using the template called “First Person” as the testing grounds today (which is under the “Blueprint” section when first opening up Unreal). Also, you should have 4+ gunshot sounds ready to use for the actual randomization.
As your mom probably told you when you were little, you need to clean your room before you can play with Theodore from across the street! The same applies here, you need to get in the habit of keeping a good folder structure, even with something as simple as this! So right-click in the content browser and create yourself a folder called “SFX”.
In that folder, right-click again but this time choose to make a new sound cue… (Sound cues can be found under the “Sounds” section”) call this “Rifle_Fire”.
Next up, take the gun sounds (that you’ve hopefully already prepared because I told you to… right?!) and drag them into the content browser.
Double-click on the “Rifle_Cue” sound cue to open and behold the wondrous sight of a ~*~*~*~*Sound Cue~*~*~*~*~
This looks pretty bare bones right now, and if you’ve never dealt with Unreal before, you probably think this looks super boring or confusing! But keep trusting me! Highlight the sounds you just brought into the session and drag them onto the dark grid. Your sound cue should now look very close to the picture below.
The way that we randomize between these sounds is to add a “Random” node in between the sounds and the output. Every box you see in a blueprint or sound cue is basically a node which can be connected, manipulated and controlled in various different ways. Now, right-click on the dark grid, search for random and then choose the “Random” node.
If you have more than two sounds to randomize between, you need to add more inputs. You do that by pressed the “Add Input” button on the random node… press this until you have the same amount of inputs as you have sounds. Now drag out from each white circle on the sounds, and connect them to an input. Also connect the random node to the output. (This is all shown in the picture above)
Try pressing the play button in the top left to hear your sounds being randomized… Simply amazing.
To get your sounds into the game, navigate back to the Blueprints folder in the content browser and open up “FirstPerson Character” and behold the wondrous sight of a ~*~*~*~*Blueprint~*~*~*~*~ (okay.. I’ll stop). Ignore everything you see here and navigate down to the “Spawn projectile” section of the blueprint. After looking around here for at bit, you’ll come across a “Play Sound at Location” node that references a sound. This is the golden ticket! Navigate to your sound cue in the browser, highlight it and then press the little arrow in the aforementioned node. Or, simply just use the search function inside the node. Now your sound cue is referenced to play, instead of the old one.
Play the game to hear your sounds coming from the gun! Satisfying!
A Teeny Bit More Advanced
If you want to modulate the pitch and volume of the sounds, you simply need to add a “Modulator” node in between the random node and the output.
You could potentially also randomize between different layers of sounds. To do this you simply need to add a “Mixer” node right before the output. This allows for multiple instances of what we’ve just built to be played at the same time. Hopefully the picture below illustrates this well enough!
How This Helps You Understand Audio Middleware Better
In my experience, using Unreal Engine to setup audio systems has granted me a deeper understanding of what happens under the hood in our middleware. It’s a more visual way of seeing how the actual sound is being treated through a chain of events. So instead of just plotting down a multi-instrument in FMOD and setting the randomization options, you now see it as a timelime… a process! The more you practice this, the easier you will find middleware to be.
- If you haven’t ever used Unreal Engine before, spend some time getting used to the interface. Play the game, have fun!
- Delete the Sound Cue you just made with this guide, and try building it from scratch without help.
- Design an extra layer for your gunshot sounds and figure out how to get them to play at the same time (while randomizing of course…)
- Play around with the modulator node.. take it as far as you possibly can. When does it sound amazing, when does it sound like crap?