Any way to only have one sound play at any given time?

I’m currently working on a project aimed at children who cannot read.


All menus and buttons are narrated to aid their understanding of the game.

The Problem : Currently, the player can sporadically move the mouse over various buttons and be greeted with a cacophony of overlapping voice sounds being played.


The way this is set up:

  • All buttons have their narration
    sounds played using the “On Hover”
    setting in UMG.
  • Some menus also have a sound play on
    construct, to explain the meaning of
    the particular screen.
  • This is a 100% blueprint based project.

I have my sound classes and mix set up, and all of the sound files are set to have a maximum of 1 concurrent play, meaning the sound cannot be repeated unless the first has finished.

However, this only applies to individual sounds overlapping themselves. Is there any way of applying this logic to an entire sound class? Meaning that only one sound in the narration class can be played at any time?

Any help would be greatly appreciated.

Thank You.

You need to playout sound from single audio component, it works like player and single audio component won’t play 2 sound cues in same time. You will need to stop sound, switch sound and play it

Thank you for your answer, though I’m not sure I fully understand.

I am using UMG’s button hovers to activate the individual sounds since I have need of these over various levels and menus.

I have updated my original post to make my situation more clear.

You can do this easily if you’re willing to write a little C++ Blueprint utility function. Something like this:

bool UUtilities::PlaySoundIfNotRecentlyPlayed(UObject* WorldContextObject, USoundBase* Sound, FVector Location, float MinimumTimeElapsed, float VolumeMultiplier, float PitchMultiplier)
{
	UWorld* ThisWorld = GEngine->GetWorldFromContextObject(WorldContextObject);
	FAudioDevice* Dev = GEngine->GetAudioDevice();
	if (!ThisWorld || !Dev) return false;
	for (const FActiveSound* ExistingSound : Dev->GetActiveSounds())
	{
		if (ExistingSound->Sound == Sound && ExistingSound->PlaybackTime < MinimumTimeElapsed && ExistingSound->World == ThisWorld && some_other_custom_comparison_logic)
		{
			return false;
		}
	}
	UGameplayStatics::PlaySoundAtLocation(WorldContextObject, Sound, Location, VolumeMultiplier, PitchMultiplier);
	// or some other sound playing function
	return true;
}

Add your own custom logic at some_other_custom_comparison_logic to decide if the sound shouldn’t be played.

Thank you for the reply.

Sadly, I have absolutely no idea on how to code - especially with C++.

I’m using 100% blueprints here. I understand the logic of the code you posted, but have no idea on how to achieve this with BP (if it is possible at all)

Isn’t it somehow possible to use a simple bool for that? I don’t know if this would really work, but is it possible to get the remaining time of a sound?

You could do this for every sound (a function that gets the sounds as a paramter would be helpfull then). Just chech if the bool (e.g.) “bIsPlaying” is false and only then play your sound. If you play your sound, set the bool to true and get the remaining time of the sound. If the remaining time is less than 0.1 or something like that, set the bool back to false.

I’m totally sorry if this doesn’t work, since i haven’t worked with sounds yet and i have no time digging into my Editor right now. Maybe this still helps you.