Simple Audio Attenuation in Unreal Engine 4

In this guide we will be looking at adding audio attenuation into your Unreal Engine 4 game.

The Attenuation Class

Creating the Class

To create a sound attenuation class, right click anywhere in your content browser, navigate to the sounds section and click Sound Attenuation.

Creating the sound attenuation class in the advanced asset menu.

Give your new Sound Attenuation class a name and remember it as we will be using it later in the guide.

Naming the audio attenuation.

I named mine Tutorial Sound Attenuation.

Attenuation asset named.

Class Settings

Opening your new Sound Attenuation class will show these settings:

Full list of audio attenuation settings.

There are many settings that can be changed to modulate your audio to make it very realistic.

For simple audio attenuation we only need these settings:

Relevant attenuation settings for this guide.

For the demonstration video at the end of the guide I will be using these exact settings.

Attenuation Function

The attenuation function determines how the volume is changed over distance.

List of attenuation functions.
  • Linear reduces the volume equal to the distance.
  • Logarithmic reduces the volume much faster over distance.
  • Inverse has the fastest volume drop off.
  • Log Reverse reduces the volume very slowly until a large distance then it drops off very quickly.
  • Natural sound reduces the volume to imitate how sound works in the real world.
  • Custom is for creating your own curves. This isn’t recommended as it can get quite complicated.

For the majority of your sounds I recommend to use the Logarithmic function. It creates easily locatable sound and prevents far sounds from being unnecessarily loud.

Attenuation Shape

Attenuation shapes restrict sounds to a specific shape. This prevents sounds from leaking out of a specific environment.

List of attenuation shapes.
  • Sphere is for most sounds.
  • Capsule is for thin and round environments.
  • Box is for cuboid shaped buildings.
  • Cone is for projecting sound at a specific area or player.

Inner Radius

The inner radius is the size of the sphere that represents your sound at full volume.

Any player inside this sphere will hear the sound without any volume reduction.

Falloff Distance

The falloff distance is the distance the player needs to be for the audio volume to be zero.

The volume reaches zero using the attenuation function setup earlier.

Enable Volume Attenuation

This setting controls if you want the audio to lower in volume over distance. We need this to be checked.

Checkbox for volume attenuation.

Attenuating Audio

Applying the Attenuation Class

To play sounds with your newly setup attenuation class, create a “Play Sound at Location” node.

Creating a play sound at location node.

Set the Sound input pin to which ever sound file you want to play.

Setting the sound file to be played.

Create a “Get Actor Location” node and connect it to the Location pin on the “Play Sound at Location” node.

Setting the location of the sound.

Click the box with the triangle to expose the additional audio settings.

Accessing the additional settings.

The additional setting that we need is called “Attenuation Settings”. Set this to your attenuation class created at the start of the guide.

Setting the attenuation class.

Now your sound will use the Sound Attenuation class when played and will be specialized in the world at the location specified.

Video Demonstration

Conclusion

These are just the basics of attenuation in Unreal Engine 4. I recommend spending time to figure out which is the best attenuation function and attenuation shape for the atmosphere you want to create.

To see the individual plotted graphs for each attenuation function click here for the official Unreal Engine 4 wiki page.

Leave a Reply

Your email address will not be published. Required fields are marked *