Unreal Engine Part 11: Linking audio to actions and objects

In chapter 11 of Rob Redman's comprehensive video introduction to Unreal Engine, learn how to link audio to actions and objects...

Previous tutorials

Part 1: Setting up a new project
Part 2: Introducing materials and landscapes
Part 3: Adding foliage and rocks
Part 4: Particle smoke
Part 5: Introducing the skybox
Part 6: Setting up cameras and post-effects
Part 7: Teleporters
Part 8: Adding random assets
Part 9: Destruction
Part 10: Adding sound

In the last chapter I showed you how to add a sound effect which plays when your player passes through a predefined area. This is very useful but what if you want to have your audio file linked to a prop or an action like a projectile impact?

In this chapter I'm going to show you a different setup, where the audio is triggered by an impact from the default player's weapon. When you play the level you can fire at an object and that object will react with a sound.

This could be anything from a shout to a simple impact sound. I've included the sound file here for you.

Although the theme here is similar to the last chapter I think it's important to learn how to do this, as it will have a massive impact on your end result.

Step 1: Import

First up, import your sound into your audio folder (make one if you don't have one) in your content browser. Right-click this and choose Create Cue. In the Cue editor you can leave things as default, except make sure looping is unchecked.

Import your audio then create a new cue from it, so it can work in the level.

Import your audio then create a new cue from it, so it can work in the level.

Step 2: Blueprinting

At this point we need to start setting up the object we want to make a noise when it's shot. I'm opting for the statue, so select it, then in the outliner right-click it and choose Show In Content Browser. In the browser right-click it and choose Asset Actions > CreateBlueprintUsingThisAsset. Give it a name (Statue_BP) in the pop up and the editor window will open.

Choose an object that you want to make sound, and then make a blueprint from it.

Choose an object that you want to make sound, and then make a blueprint from it.

Step 3: Linking

Next we need to link our sound file to our statue, so drag the Cue, from the content browser, not the Components list of the blueprint. In the details tab turn off Auto Activation, so you control when it plays. You can adjust the attenuation settings here or in the level editor. Do what is more comfortable for you.

I set mine so it would be heard from a good distance with quite a large falloff from 100 to 0 volume.

Add the audio to the blueprint and define initial settings.

Add the audio to the blueprint and define initial settings.

Step 4: Event Graph

As with other blueprints we have dealt with, the main set up happens in the Event Graph tab of the blueprint editor, so head over there and drag in your Cue.

In your objects list, select the static mesh (which is the statue) and right-click to add an event. For this we want to add a collision for our projectile, so choose Collision/OnComponentHit.

Now drag out on the output of the cue and choose Play. Connect the nodes as shown then save and compile, then close the editor. Now choose the blueprint statue from the browser and replace the original in the level with it.

The most basic blueprint setup yields great results

The most basic blueprint setup yields great results

Step 5: Adjustments

Now you can play the level and you should find that if you shoot the statue you hear the impact. Try it from different distances to check whether you need to adjust the attenuation. Mine was fine but the overall volume was too low. If this is the case for you open up the Cue and increase the Volume Multiplier in the Sound section of the Details tab.

Globally adjusting volume is easy, with a single control needed.

Globally adjusting volume is easy, with a single control needed.

Top tip: Blueprint related sounds

The main reason I wanted to show this method is so that you can get some versatility. Use different sounds with different blueprinted objects, to replicate the sound of various materials being shot. This will add depth to your level that will probably be unconsciously heard but will make for a more involving experience.

Grab a copy of 3dtotals Unreal Game Engine tutorial book

Related links

Part 1: Setting up a new project
Part 2: Introducing materials and landscapes
Part 3: Adding foliage and rocks
Part 4: Particle smoke
Part 5: Introducing the skybox
Part 6: Setting up cameras and post-effects
Part 7: Teleporters
Part 8: Adding random assets
Part 9: Destruction
Part 10: Adding sound
Download Unreal

Fetching comments...

Post a comment