Play audio with attenuation only for specific player?

I’m currently implementing a bullet fly by sound effect so that players can get feedback about where shots are coming from when a bullet comes close to but misses them.

It’s working great now however there is one problem- when I’m close to an enemy (currently AI with identical character setups to the human players) I can hear the bullet fly by sound being triggered for them when I shoot next to them.

For this reason I’d like only the player getting shot at to ever hear the audio, and not have nearby players hear it too.

I can’t use the “play sound 2D” node as then the attenuation would be lost and it’s vital to pinpoint the direction of the shot.

Thanks,
Eoin

It isn’t as if you are near a player that has a bullet fly by THEM, you can hear the bullet fly by sound even though the bullet didn’t go near you, it should only play for the character that had the bullet go by them, no one else. The player character being a child wouldn’t change the way the functionality is called.

You can add an audio component in your character and fire its event only when the projectile overlaps a volume specific to only your player character head, only him will have this volume so only him will trigger this event. Hope it helps

Your player character should be a child of the character whit that functionality only inside it.
Anyway I think it’s perfect as it is now if they are near your character.

This is currently more or less how it’s set up but with line traces instead so the audio is played at the point that the line trace hits the collision sphere around the player, however the problem is that nearby players can still hear the audio triggered by other players since the falloff of the attenuation must be a minimum number to be audible by the player that was hit. There’s no way to basically do a “play audio 2D” except with attenuation?

Sorry, play sound 2D is designed for user interfaces.
The best way is attenuation logarithmic, that is de4signed for your purpose.

I ended up making it so that if the distance of the shot is below a certain amount, the sound won’t play- this eliminated most of the sounds being heard from players being up close and spamming bullets, good tip on the logarithmic attenuation btw, should take care of most other cases!