set3DOcclusion function does not actually pass the values

Hi, recently I wanted to add a simple audio occlusion effect to my project. After quick google, I found the “set3DOcclusion” function that I can call on my ChannelGroup. The problem is that the function does nothing where stuff like “setVolume” does.

When debugging, I tried getting the information through “get3DOcclusion” and I was confused as it returns 0 (even though I set it to 1).

public class FirstPersonOcclusion : MonoBehaviour
{
    [S] EventReference eventReference;
    [S] EventInstance Audio;
    [S] EventDescription AudioDes;
    [S] StudioListener Listener;
    [S] PLAYBACK_STATE pb;
    
    [S] LayerMask OcclusionLayer;

    [S] bool AudioIsVirtual;
    [S] float MinDistance;
    [S] float MaxDistance;
    [S] float ListenerDistance;
    [S] Color colour;
    ChannelGroup group;
    
    float a;
    float b;

    private void Start()
    {
        Audio = RuntimeManager.CreateInstance(eventReference);
        RuntimeManager.AttachInstanceToGameObject(Audio, GetComponent<Transform>(), GetComponent<Rigidbody>());
        Audio.start();
        
        AudioDes = RuntimeManager.GetEventDescription(eventReference);
        AudioDes.getMinMaxDistance(out MinDistance, out MaxDistance);

        Listener = FindObjectOfType<StudioListener>();
    }
    
    private void Update()
    {
        Audio.isVirtual(out AudioIsVirtual);
        Audio.getPlaybackState(out pb);
        ListenerDistance = Vector3.Distance(transform.position, Listener.transform.position);
        
        if (!AudioIsVirtual && pb == PLAYBACK_STATE.PLAYING && ListenerDistance <= MaxDistance)
        {
            @group.set3DOcclusion(1f, 1f);
            @group.get3DOcclusion(out a, out b);
            Debug.Log(a + " "+ b);
        }
    }

I also fiddled around with the initialization flags like “FMOD_INIT_CHANNEL_LOWPASS” but that didn’t help either.

How exactly does the function work and how to use it?

Hi,

ChannelGroup::set3DOcclusion is a function designed to be used with the Core API’s Geometry Occlusion system, and requires you to import geometry into FMOD for it to use to calculate occlusion. If you simply want to be able to adjust occlusion based on a value that you’ve calculated, I would recommend creating a parameter in Studio, and using that parameter to automate volume and/or filter cutoffs. Then, you can use EventInstance::setParameterByName etc. to set the parameter to your calculated occlusion value.

Hope this helps!