Skip to content

Audio Utils

Introduction

The audio utils class is used to easily play sound effects

Dependencies

The AudioUtils relies on other components of this plugin to work:

  • Logger: Used to log useful information to help you debug any issues you might experience

API Reference

Functions

Name Description Params Return
PlaySound2D Play a 2D sound WorldContext (UObject*)
The top level object representing a map

SoundFX (USoundBase*)
The USoundBase to play
PlayRandomSound2D Play a random 2D sound WorldContext (UObject*)
The top level object representing a map

SoundFX (TArray)
The array of USoundBase to select the random sound from
PlaySound Play a sound at the specified actor's location Actor (AActor*)
The actor where the sound will be played

SoundFX (USoundBase*)
The USoundBase to play
PlayRandomSound Play a random sound at the specified actor's location Actor (AActor*)
The actor where the sound will be played

SoundFX (TArray)
The array of USoundBase to select the random sound from

Blueprint Usage

You can use the AudioUtils using Blueprints by adding one of the following nodes:

  • Ultimate Starter Kit > Audio > Play Sound2D
  • Ultimate Starter Kit > Audio > Play Random Sound2D
  • Ultimate Starter Kit > Audio > Play Sound
  • Ultimate Starter Kit > Audio > Play Random Sound

C++ Usage

Before you can use the plugin, you first need to enable the plugin in your Build.cs file:

PublicDependencyModuleNames.Add("USK");

The AudioUtils can now be used in any of your C++ files:

#include "USK/Audio/AudioUtils.h"

void ATestActor::Test()
{
    UAudioUtils::PlaySound2D(WorldContext, SoundFX);
    UAudioUtils::PlayRandomSound2D(WorldContext, SoundFX);
    UAudioUtils::PlaySound(Actor, SoundFX);
    UAudioUtils::PlayRandomSound(Actor, SoundFX);
}