Hi there, I have an issue implementing some of my sounds.
For exemple, I have a cubic room. Against one of the wall there is a Hifi playing sounds. When I am in the room, I can hear the Hifi and the sound’s volume goes down as I move away from it. So far so good.
The only thing is that on the other side of the wall (in another room), I can still hear the Hifi as if the wall wasn’t there! The sound should be off or at least really softer.
I don’t know how to fix this since I can only deal with spheric audio zones.
Thank you in advance for reading me and helping me out!
Worst part is, FMOD has this functionality out of the box- it's just that Unity doesn't have any interface to it, and so you can't implement the native FMOD solution. You need to rely on hacks like audio zones.
I know this doesn't help you now, but I'll be releasing a rather cool audio toolkit in the Asset store in a couple months that would take care of this for you.
Im having the exact same problem at the moment, I have tried to do this using RayCast but I cannot get it working proberbly since there is no 360 degree Raycast implemented.
360° raycast? why? all you need to do is cast a raycast (or sphere cast) from the listener to every audiosource that should be "silenced" if not visible. If it's not visible, you can change the roll-off values so it's fading-out earlier.
You have to attach this script to every audio source that should be able to be occluded. You have to assign your player to the Listener transform variable. Another way would be to make the Listener variable static and assign it from the player’s script.
public static Transform Listener;
// In your players script:
void Start()
{
//[...]
OccludableAudio.Listener = transform;
}
This way you only have to assign it once.
Don’t forget to setup the layermask to specify what colliders should occlude the audio.
You could set up some, say, Box colliders and use them as proximity detectors to tell the audio to attenuate accordingly. You’d want to change the volume the player hears rather than the source if it’s multi-player (or at least, not propagate the volume to other players).
Worst part is, FMOD has this functionality out of the box- it's just that Unity doesn't have any interface to it, and so you can't implement the native FMOD solution. You need to rely on hacks like audio zones.
– syclamothI know this doesn't help you now, but I'll be releasing a rather cool audio toolkit in the Asset store in a couple months that would take care of this for you.
– DaveAIm having the exact same problem at the moment, I have tried to do this using RayCast but I cannot get it working proberbly since there is no 360 degree Raycast implemented.
– hrlarsen360° raycast? why? all you need to do is cast a raycast (or sphere cast) from the listener to every audiosource that should be "silenced" if not visible. If it's not visible, you can change the roll-off values so it's fading-out earlier.
– Bunny83@Bunny83 How would you go about doing that? I can't seem to find a solution for casting rays to multiple objects
– hrlarsen