How to get direction and volume of sound that player character hears

I want to make a widget that displays a little image that shows up when there is a nearby sound, I want the image to show the direction of the sound from the player and also how loud the sound is.

I can figure out the widget side (maybe) but I have no idea how to calculate the direction of the sound from the player. I also don’t know how to calculate the volume of the sound, this is important because I will use this for the opacity of the widget.

For all sounds I am using the “Spawn sound at location” nodes. If you are good with sound in unreal but don’t understand the question I can make a mock image to show what I am trying to do.

You need to separately emit a sound “stimulus” that the GUI can latch on to. You can use the AI perception system that already exists for this, or you can build your own system.

Everytime you “spawn sound at location,” you would also emit a stimulus that says “a sound was played with loudness L at location X,Y,Z.” Your player GUI (or controller) would then listen for these stimuli, and calculate the direction by subtracting the player position from the sound position, and the loudness by dividing the played sound loudness by (typically) the square of the distance to the sound source from the player.

It never occurred to me to just use AiPerception on the players character, that would this so much easier.
I can’t seem to be able to get the apperception to work on the player, do I need to do something different than when I use it on the AI? When I go to debug mode you cannot see the radius of hearing or anything.

Update: It does work whenever I shoot a gun but that seems to be the only sounds it picks up

The AI perception component still needs you to tag the sound so it can be “heard.” Check out Report Noise Event:

I’m missing something very important because this isn’t working at all, below is what I have and it still doesn’t register any noises EXCEPT for gunshots. I’ve looked into the sound cues but I can’t figure out what makes them so special.
Screen Shot 2022-07-11 at 1.31.24 PM

Also I still don’t get how to tag sounds for the Report Noise Event

Here’s what I find when I google “unreal engine report noise event”:

Again, just “play a sound” is not enough. You need to also separately report the event to the AI system when you play the sound, by calling this node. Presumably, whatever plays the gunshot sounds, does this.

When I started test with Report Noise Event it wasn’t working at all, then I closed my computer and when I came back it works so maybe that was just a bug?

The only issue I have now is how do I report a noise event on a sound cue that is looping? The play sound node is followed by the report noise node, but the sound played is a loop so it only triggers the noise report the instant the sound starts and if you walk into the sound after it has started it will never register in the aiperception . I could use some loops to keep triggering the report noise event but that seems like it would maybe hurt performance.

Perhaps use a timer that fires once a second while the sound is playing, and clears when the sound stops?