Sound Rolloff question

I wish to keep an AudioSource volume fairly strong until a certain distance away from it, and then have it roll off sharply. Example; be 3m away from an object and still have strong volume, but when 10m away, volume is pretty much 0.

After much trial and error, no apparent combination of AudioSource Rolloff / Volume tweaking achieved this desired effect; was either too soft unless standing next to the source, or too loud when far away.

Am I missing something regarding sound tweaking? Or is this currently impossible without some dynamic rolloff scripting…?

I’d love even rudimentary sound volumes support (using collider-like gizmo interface) but i suspect that is more a ‘wish list’ post, heh.

Anyone?

I noticed that too and I couldn’t find a good solution. Maybe something like this would do it:

var target : Transform;
function Update ()
{
     if (Vector3.Distance (transform.position, target.position) > 3)
         audio.rollOffFactor = 20;
     else
          audio.rollOffFactor = 0.5;
}

Thanks for replying Daniel; I did consider tweaking rolloff based on distance, but Roll Off Factor doesn’t appear in the scripting API (unless I’m missing it).

I guess we can do is wait until it’s exposed, or Unity supports some form of ‘intensity’ value for sound sources.

What we did in GC:Palestine was to just modify the volume and do our own attenuation. It was quite easy, so play along with that…

Yep, I’ve found that the options for audio are kind of limited so I often end up scripting them. (And no, you can’t script rolloff.) It would be nice if there were some different choices for the type of rolloff, like how Blender (and other apps) work with proportional editing: smooth, sphere, sharp, linear…that sort of thing. Because not all sounds and all situations are the same, and what might be mathematically correct doesn’t always sound right.

–Eric