Audio Sources - Simulate Microphone in-game

Hi all,

I’m trying to simulate an in-game microphone, where you can only hear something if you care looking towards it.

Right now my solution is to use Raycasts and just lower/mute the audio source when not looking at it, but I was hoping there would be a different way to do this?

instead of rays, how about just getting a collection of nearby sources and checking if they are infront or behind with

or if it needs to be in a cone infront, get a ‘look’ vector (a-b), and check the dot product with the forward vector.

Wow, this is a great suggestion. Thank you! I would like to use a cone system.

I’m a bit confused by your last line…could you elaborate on what you mean?

The only advantage I can see with my current system is that I have a nice smooth dropoff in volume when moving the mic away from the source (because I am accessing the source volume and lowering it). I’m not sure how I would do that with your suggestion…any ideas?

I just want to avoid going from no sound to full sound in a split second.

Either dot or angle between the forward vector and the from-to vector

Dot gives a nice 0->1 range if you normalize the compared vectors (-1 → 0 if the source is behind)