Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Audio Audio Occlusion | Raycasting Question...Gradual occlusion as listener approaches edge of object?

Discussion in 'Audio & Video' started by blakeleesanchez, Nov 2, 2018.

  1. blakeleesanchez

    blakeleesanchez

    Joined:
    Nov 2, 2018
    Posts:
    2
    Hey guys, does anyone know how to determine the distance a Raycast is to the edge of an occluded object? This way I can gradually release the occlusion as the listener moves closer toward the edge of a wall for example, instead of snapping instantly from occluded to not occluded.
     
  2. ReaktorDave

    ReaktorDave

    Joined:
    May 8, 2014
    Posts:
    139
    Instead of having to compute the distances to all possible non-occluding points of an occluding object, I'd rather keep the system the way it is right now, but transition between the occluded state and non-occluded state. So let's say your occlusion effect is a lowpass-filter. Instead of hard setting the frequency to 500Hz during occlusion and 15000Hz during non-occlusion, you'd start a coroutine that moves from 500Hz to 15000Hz over time. Will save you a lot of unnecessary geometry checks.