How to reflect / bounce audio off of a 3D Object?

I’m working on a project that will require an audio source (emitter) and an audio listener (the player) – Easy. What I need is the ability to bounce / deflect / block an audio emitter based on 3D environment elements (buildings, etc …). Additionally, if the audio emitter is blocked by one 3D Object, but bounced off of another before being received, the receiver needs to detect the angle (or line of direction) from which it is hearing the audio emitter.

Does anyone know how to do this, or have any idea on how to achieve it?

Thanks in advance!

Edit (5:25pm 5/26/2011)

How about using a (really large for long distances) a spherical collider that grows in size like a balloon until it “hits” the player. The player will be surrounded by 8? colliders in an effort to better determine which side the signal is hitting. However, this spherical collider idea doesn’t take into account 3D objects and obstructions.

Here’s the problem…Unity’s audio stuff sucks. If you want better stuff, just send angry messages demanding write access to audio buffers, which would allow you full access to the power of FMOD! But, we don’t have that, so for now you’ll have to fake it. I’ll write up a longer answer if you need it on faking it. One thing though, if you’re using a 5 mile radius terrain, you might want to go into Project Settings-> Audio and change the speed of sound a bit, or you’ll get a delay.

Thinking about it, it’s quite hard to fake the sound bouncing. The problem is that sound isn’t stopped - it pays no notice to objects. But I’m thinking, why not have another audio source close to the player/whatever? But with a volume/pitch which you change through script. And the closer you get to the ‘real’ place (where there is no source) the louder the source gets. That’s what I’m thinking of, anyway.

Just an idea and i don’t really know how to implement this but do you actually need the Sound to bounce,

I was thinking you could use a load of ray casts possible to create all the bouncing effect and then if the ray cast eventually hits the player/receiver you play the sound file attached to the player

Just an idea and not sure how you would implement it but I’m not sure you can reflect sound as Muzz5 said it doesn’t get effected by objects so this might be an alternative

hope its helpful

Scribe

ok Im not sure if this will be at all useful for what you want but you could try something like this:

var targeter : Transform;

function OnCollisionEnter(other : Collision) {
    print("First point that collided: " + other.contacts[0].point);
    var collision = other.contacts[0].point;
    
    targeter.LookAt(collision);
}

basically I have my person(capsule) and inside my capsule there is a small cube (targeter). my code gets the point that something collided with the capsule and makes the cube inside look at it. I had to do it like this because I didnt have anyidea of how to transform the Vector3 into an angle so I made the cube which is at the centre of my person look at it and I used the rotation of the cube to work out its angle in relation to my person.

It works but in a round about way

as I said I’m not sure it will be really any help as the sound isn’t a physical collision but you might be able to work off and adapt this

Scribe

Hi Muzz5,
Before you go all crazy about how Unity’s audio suck, think about how you would implement reflection of audio with FMOD?. You will probably end up with some raycasting against occluding objects, some LPF, Reverbs, volume and pitch manipulation. All nicely exposed by Unity. Audio Buffer access (which is on the way) will give you one thing here, the ability to rewrite effects, mixing etc… Building a reflection system from that will probably take some time.

cheers,
søren