Unreal Engine 4 Audio Tutorial
- Getting Started
- Playing Music
- What is an Animation Notify?
- Creating an Animation Notify
- Moving an Animation Notify
- Playing the Footstep Sound
- What is a Sound Cue?
- Creating a Sound Cue
- Changing the Pitch of a Sound
- Playing a Sound Cue
- What is Spatialization?
- Enabling Spatialization
- Playing a Sound in 3D Space
- Adding the Rain Sound
- Setting Up Attenuation
- Fading Out a Sound
- Sound Classes and Sound Mixes
- Creating the Sound Classes
- Creating and Adjusting a Sound Mix
- Activating a Sound Mix
- Where to Go From Here?
In video games, the term audio is used to refer to things such as music, dialogue and sound effects. In this era of gaming, if your project does not have audio, it can seem unpolished and incomplete.
Audio also helps increase the immersion between the player and the game. Music provokes an emotional response. Dialogue develops characters and the story. Sound effects provide feedback and believability. All of these can turn a good game into a great game.
In this tutorial, you will learn how to:
- Play music and loop it
- Play a sound effect at specific points in an animation
- Modulate the pitch of a sound every time it plays
- Pan and adjust the volume of a sound depending on its location in 3D space
- Control the volume of music and sound effects independently using the UI
Please note, you will be using Blueprints in this tutorial. If you haven’t already, please go through the previous tutorials as they cover different areas of Blueprints.
It is also recommended to use headphones for this tutorial as you will learn how to spatialize audio.
- Part 1: Getting Started
- Part 2: Blueprints
- Part 3: Materials
- Part 4: UI
- Part 5: How To Create a Simple Game
- Part 6: Animation
- Part 7: Audio (you are here!)
- Part 8: Particle Systems
- Part 9: Artificial Intelligence
- Part 10: How to Create a Simple FPS
Download the starter project and unzip it. Open the project by navigating to the project folder and opening SkywardMuffin.uproject.
Press Play to start the game. The goal of the game is to touch as many clouds as possible without falling. Click the left-mouse button to jump up to the first cloud.
The game is relaxing, isn’t it? To emphasize the feeling of relaxation, the first thing you will do is play some calm piano music.
Go to the Content Browser and navigate to the Audio folder. Here, you will find all the sounds you will use in this tutorial. You can listen to them by hovering over their icon and then clicking the play icon that appears.
Playing music is as simple as dragging and dropping the sound asset into the Viewport. However, the music will only play once. This is because you need to manually enable looping within the asset. Double-click on S_Music to open it.
A new window with a single Details panel will appear. Go to the Sound Wave section and enable Looping.
Next, go back to the main editor and then drag-click the S_Music asset into the Viewport.
This will create an AmbientSound actor with S_Music as the sound source. This actor will automatically play S_Music when the game starts.
Press Play to listen to the music. After 17 seconds (the length of the music), it will loop and play again.
Next, you will add a sound effect whenever the muffin takes a step. To do this, you will use an Animation Notify.
What is an Animation Notify?
An Animation Notify allows you to trigger an event at a specific point in an animation. You can use them in many different ways. For example, you could create a Notify to spawn a particle effect.
In this game, the restart button appears as soon as the muffin touches the ground. However, using a Notify, you could make it appear at the end of the death animation.
In this tutorial, you will Animation Notifies to play a sound when each foot hits the ground.
Creating an Animation Notify
Navigate to the Characters\Muffin folder and then open SK_Muffin_Walk. This will open the Animation editor.
In the panel below the Viewport, you will see an area called Notifies. The light grey area is a Notify Track. This is where you will create and manage your Notifies.
Frame 10 and frame 22 are when each foot hits the ground so you will need to create a Notify at both of these points. To create a Notify, right-click on the Notify Track and select Add Notify\Play Sound. This will create a Notify called PlaySound.
Next, you need to position the Notify so that it occurs on frame 10.
Moving an Animation Notify
It’s a bit hard to know where to move the Notify to because the Notify Track doesn’t indicate where frame 10 is. However, you can display a marker by using the Timeline.
First, go to the Timeline located at the bottom of the panel. Drag-click the red playhead and release when Current Frame is 10. Make sure to pause it first!
Now, the Notify Track will have a red line indicating where the playhead is.
Drag-click the PlaySound Notify and release when it aligns with the red line.
Next, you need to tell the Notify to play the footstep sound.
Playing the Footstep Sound
Left-click on PlaySound to select it and then go to the Details panel. In the Anim Notify section, set Sound to S_Footstep.
Next, repeat the process for the other foot. Do the following:
- Create another Play Sound Notify
- Move the Notify to frame 21
- Set the Notify’s sound to S_Footstep
Now, whenever the walk animation reaches frame 10 and frame 21, the Notifies will trigger and play the S_Footstep sound.
Close SK_Muffin_Walk and then go back to the main editor. Press Play and start walking around to hear the footsteps.
After listening to the footsteps repeatedly, players may notice something. It’s the same sound effect each time! If only there were some way to vary the sound each time.
In the next section, you will play a sound effect when the player touches a cloud. But this time, you will vary the sound each time using a Sound Cue.
What is a Sound Cue?
A Sound Cue is an asset that allows you to manipulate multiple sounds and combine them. You can then treat the Sound Cue as its own sound. Anywhere you can use a regular sound, you can use a Sound Cue instead.
Here is an example of a Sound Cue using a Concatenator to play three sounds in succession:
If you use a Random node instead, you can select a random sound every time you play the Sound Cue.
In this tutorial, you will create and use a Sound Cue to change the pitch of a sound.