Working with Sound in Unreal Engine

How to work with sound in the Unreal Engine?

Sound Cue

Sound Cue is a Blueprint interface within which there's possible to program sounds (e.g. different sound based on a surface that has been hit or randomize it). Any sound file can be added with a Wave Player node.

Creating a Sound Cue

Sound cue can be created by clicking with right mouse button in the Content window and then selecting SoundsSound Cue.

Sound cue can be created with C++ from UBlueprintFunctionLibrary inherited class as below:

USoundCue* SoundCue = Cast<USoundCue>(CreateAsset(AssetPath, USoundCue::StaticClass(), nullptr, bOutSuccess, OutInfoMsg));

Name Sound Cues files with A_ prefix.

Sound Cue options

  • Random - Randomization between more sounds
  • Modulator - Randomization of a sound volume

Sound Cues can be attached as a source file code into USoundBase variable same as Sound Wave.

Sound Attenuation and Spatialization

Both are cofigurable within boxes in the Sound Cue detail window. There's possible to create also a file that can be attached to sound files and override their Attenuation settings. Use ATT_ name prefix for these files. Within the file's Detail window, both Attenuation Distance and Attenuation Spatilization configuration can be found.

Ambient Sound Actor

  • Suitable for Background music with some Ambience. It plays sound everywhere, thus it does not matter where it's placed in the level
  • Accessible from Place Actors window

Play Sound At Location

It can be triggered either through BP node Play Sound at Location or C++ code UGameplayStatics::PlaySoundAtLocation().