Disabling sound coming through walls

Hey, I have a problem with sounds and solid walls. I couldn’t find an answer on the web and thought to ask here. Here we go:

12608-sound_problem.jpg

Red lines = walls

S = sound source

Green circles & arrows indicate the sound distribution in the room.

P1 is a point where the player can be. Here the player can hear the sound normally.

P2 is another point where the player can be. But other than at P1, the player shouldn’t be able to hear the sound at P2 with the same volume as P1 can, because there is a wall between the player and the sound now.

I found that unity ignores walls which is a pity. If I want a monster to hide in one room the player shouldn’t be able to her it when he is outside the room, next to the wall where the monster is.

My add-on Audio Brush addresses this directly. It will be available as soon as I get the licensing in place. If you would like to test it though, contact me through the web site. http://qlcomp.com click on Unity then Audio Brush

A basic way is to use a linecast to check if a collider is in the way between something that generates the audio and the player. There’s no way for Unity to do this automatically, since lots of sounds should still be audible through walls, depending on the material and thickness, so it’s up to you to decide how you want to handle audio damping based on your conditions.