Adding Sound Attenuation to my "Play Sound at Location" prevents the SFX from playing

Hello there,

I currently have an SFX that, when my (enemy in this case) dies, it plays an SFX at a specific moment, I’m also using “Sound Attenuation” for the SFX so that there’s some variation to it depending on how far/close the player is to my “target” (which in this case is the mesh)

To the “Play at Location” node, I’ve also added a “Sound Attenuation” but when I do that, the SFX isn’t playing at all as intended (but removing it plays the SFX with not problem but that’s not what I want), no matter how close I am to the mesh and so far, I’ve tested:

  • Using Sound Cue(s) and adding a Attenuation node but the issue still persists
  • Inputting astronomically high values on the “Inner Radius”/“Falloff Distance” (like 20k and 50k values)
  • Referencing this post, On the audio file itself, I went to “Voice Management” → “Virtualization Mode” & tried to change some options here but nothing
  • I’ve also set the “Volume Multiplier” to 100 but that didn’t do anything either
  • Just adding the normal SFX and the Sound Attenuation to it but again, nothing

I think I’ve tested just about everything I can, and I would appreciate ideas on what I could be missing, below there’s a screenshot of the “Sound Attenuation” settings & a link to part of the blueprint

Other information
Sound Attenuation settings:

MetaSound setup:

That’s the first thing I thought of, that when the volume reaches 0 or is out of reached it gets stopped. But I see you have tested that case.

Screenshot of code is a snippet, so can’t see everything going on. If with what you got there the audio works fine without attenuation, skip next part. otherwise / general advise:

Can still be a lot of things, so best to debug by testing one change after another, and not make multiple changes at once.

on the screenshot i see a number of nodes (delay, timer, deletion) which can act cursed. First off you need to put breakpoints on the blueprint nodes, run the game and see if all of the breakpoints get hit. You can read about breakpoints here.

Next be sure that the timer runs properly, and that deletion of any actor or component (your code screenshot suggests it) does not influence (stop) the sound played.

If the sound (should) play after inspecting that, but remains silent with no clear cause, I suggest creating a clean environment (new blueprint, no complexity) where you just play the sound immediately. That removes the complexity of the surrounding code while investigating.

If you are certain attenuation itself is the problem, you can start from there. You’d want to post the version number of the engine you are using and check online if there is a known bug for it, optionally make a copy of your project and test it in another engine version as it is.

I’d avoid doing so and stick to common values. “crazy” values only behave properly if developers deal with them properly in their code.

Also, you’ve probably browsed a ton of posts already but I’ll post this one here

Sound Attenuation NOT working

There’s so much to configure that can go wrong :slight_smile:

Hey there & thank you for answering,

Here’s the whole Blueprint, I probably should’ve posted it in the beginning but it’s kinda large: Enemy "state" thing posted by anonymous | blueprintUE | PasteBin For Unreal Engine

I’ve added a breakpoint on “Set Timer by Function Name” & the “Play Sound at Location” node and it looks like that it works as it should?

I will take a look and see if I can find any bug report regarding Sound Attenuation for Unreal Engine 5.5.4

That timer method looks odd. Why use that timer node for “play ignite”? I’m just starting a test project right now to see how that timer node functions and all float inputs appear to be delay factors. What could be cursed as well is that this delay might be longer than the time before the actor is deleted.

I will admit, that method of playing it isn’t preferred and it’s something I did in a state of “just throw everything at the dang wall and see what happens” and I used to see if I could create a nice timing when the mesh of my “enemy” dissolves and try and match the SFX to when the Mesh had fully dissolved

I wanted to use the Timeline that I call “Dissolve Over Time” & used an event track in an attempt to play the SFX but I got no reaction from that either, I had a print that did print messages but no audio from the sound

I need to check that last part again

EDIT: Yeah I can make it print

Using an Event Track in the “Dissolve Over Time” Timeline, I could make it play my desired SFX as it should (as long as I removed the “Sound Attenuation” from it), So I know that the “Play Sound at Location” works, it’s just that adding “Sound Attenuation” makes it wonky for some reason

Here’s an “update” to part of that blueprint: Quick Sound Attenuation update posted by anonymous | blueprintUE | PasteBin For Unreal Engine

Spoilers, it’s a bit of a mess

I tested a clean project on 5.5.4, created a new actor and placed it on the default level.
New actor contains a beginplay event playing the sound + attenuation. all options are default.
It works for me.

Can you do the above steps and place the actor on your level with your sound file? (new actor, begin play, play sound. (i played it at location 0,0,0 though)).

If it then still does not work, something on your project level or assets differs from the default which causes your problem. To further rule out external causes you could create an entire new clean text project like I did. If the problem then occurs, there is something more complex going on (since it works for me, on my device and my OS).

Yeah, I can make it work, both creating a clean blueprint with pretty much basic values & putting the “Play On Location” node at the start of my “Enemy” blueprints “Event BeginPlay” as well

I know for sure that it works

I even created a clean “Sound Attenuation” asset as well and the issue persists

Ok but if you create a 100% new clean project 100% default values and go through my steps, does it still happen?

  • Zipping mine, need a few minutes

I think I’ve discovered something interesting

In the “Switch State” thing that I have for my Enemy, I have this “Attack” state, I also have towards the end of that series of blueprint nodes, another Timeline that’s virtually the same as my “on death” Time line.

Doing the same thing with this timeline, where, I’ve added an Event track that plays the SFX when the “enemy” dies after an attack seems to make the attenuation work?

I think you’re still testing in the complex environment :slight_smile: it’s easier to debug things one at a time in the most simple situation, where it works in the project I’m zipping for you.

Does it work here?

TestProject.zip (23.7 MB)

Then I’d try to play the sound + attenuation in your code as early as possible (say BeginPlay) and check until which point it works, to pin where it breaks. Your use of timelines , delays etc overcomplicates.

I did it inside my enemy blueprint and it worked as it should, in Event BeginPlay I mean of the Enemy Blueprint

that is good news, then the only thing left is finding where it breaks between the original code position and BeginPlay. You should play the sound file as early as possible near where you originally wanted to play it, fully avoiding the delays and timers, see if it still works. If it still looks complex (say there are 10 things that could be it), then simplify instead of trying to debug all that.

Try playing the sound here directly:

I can make it work early on inside the “Destroy the Enemy” Switch state thing I got going on, so that’s nice I guess?

The “Destroy the Enemy” part is a lot simpler compared to the other “Attack the Player” switch state that I got going on

Yeah that works without a problem

If it works it works :slight_smile: . I strongly advise keeping it as simple as possible and especially avoid delays, timers, and such. Delays pull logic out of order. Say if one delay deletes your actor before the other delay was supposed to play the sound effect, you already got a hard to debug bug.

If you want to refactor the code at some point in the future to separate (and simplify) things a bit, I can recommend removing the Tick, the switch, the delays and timers. Instead you can use delegates (observer pattern), which means if X happens responding method(s) get called automatically for the event right away and without pulling things out of order. that way you can separate your code into more manageable bits that have their own purpose.

https://www.youtube.com/watch?v=ayCEqL7XFZY

https://youtu.be/euy3UfooaXU?t=61

That pattern is used everywhere in input, animations and just anything custom you want to make (say a component tracking player health, broadcasts delegate “death” when health reaches 0), then the character (the listener) responds with “play sound: death”. That is how you pull things apart into smaller cooperating systems. Otherwise your switch keeps growing :slightly_smiling_face:

The thing that I find weird, is that I can make the SFX with Attenuation work in one part of the Switch Statement tree (that in context, is one of the more complicated parts of the tree) but not in the part of the tree (that’s pretty much on Death) that is the 2nd simplest of the “Switch” branches, that what’s confusing me

But will take a look at the links that you’ve provided

So something tells me that you are deleting the actor or component required to play the sound, before the sound is supposed to play. possibly, probably bug introduced with the delays if I’m right.

If you take a look at the end of the following parts of the “Switch” tree: Look at Destroy enemy and Attacks the Player posted by anonymous | blueprintUE | PasteBin For Unreal Engine

At the end of of the, the Timelines are the same, they use pretty much the same setup, same values, same everything.

The difference here is that the “Attacks player” part of the tree functions as expected, while the 2nd simplest “branch” doesn’t for whatever reason