Event MINIMUM_DISTANCE and MAXIMUM_DISTANCE returning -1 all the time


I’m trying to get 3D event min and max distance in Unity 2019.3.15f1.
I used FMOD Studio 2.00.09 example project with this code.

void Start()
    FMOD.Studio.EventInstance gun = FMODUnity.RuntimeManager.CreateInstance("event:/Weapons/Machine Gun");
    FMODUnity.RuntimeManager.AttachInstanceToGameObject(gun, transform, GetComponent<Rigidbody>());
    gun.getProperty(FMOD.Studio.EVENT_PROPERTY.MINIMUM_DISTANCE, out float minDist);
    gun.getProperty(FMOD.Studio.EVENT_PROPERTY.MAXIMUM_DISTANCE, out float maxDist);

And I’m getting value -1 for both.
I found a similar post some time ago with the previous version:

Is it related or I’m doing something wrong?


When you call getProperty on the EventInstance you are getting back the value you set (or the default). In this case that value is -1, meaning use the values from the Event data. To fetch the min / max distance authored in FMOD Studio you can use EventDescription::getMaximumDistance.

Hi Mathew,

getMaximumDistance indeed works. I was expecting I’ll be able to get value from the instance cause instance will change depending on parameters.
I’m trying to implement footstep system where other than walking I have sprint and sneak options.
Here is my setup

So by changing Speed param I’m getting different volumes.
What doesn’t seem to work is when I added Spatializer override, cause max distance is still default 20m from Master track and not the one I’m setting by params. And if I remove Master Spatializer then I get 0 for max distance.

Is this doable or I need to take different approach?

If you plan on using the override feature within Unity your query logic will be slightly more complicated. First call getProperty on the instance, if it returns -1 then call getMaximumDistance on the description, otherwise use the instance value. If you remove the spatializer then that event will have no min/max distance.

Hi Mathew,

Sorry for the late reply, I finally managed to try this out.
I’m not sure if this is how you meant to try it out but it didn’t work for me. This is the method I’m using:

void PlayFootstep(int surfaceType, int speed = 0)
    FMOD.Studio.EventInstance Footstep = FMODUnity.RuntimeManager.CreateInstance("event:/SFX/Footsteps/Footsteps");        
    FMODUnity.RuntimeManager.AttachInstanceToGameObject(Footstep, transform, GetComponent<Rigidbody>());
    Footstep.setParameterByName(ResourceManager.Instance.references.fMODParameters.fmodParameterSurface, surfaceType);
    Footstep.setParameterByName(ResourceManager.Instance.references.fMODParameters.fmodParameterSpeed, speed);

    Footstep.getProperty(FMOD.Studio.EVENT_PROPERTY.MAXIMUM_DISTANCE, out float maxDist);
    if (maxDist < 0)
        FMODUnity.RuntimeManager.GetEventDescription("event:/SFX/Footsteps/Footsteps").getMaximumDistance(out float newMaxDist);

When I pass speed 1 for a Sneak, I would expect that max distance to be 6 and not default 20, but at first I get printed -1 for maxDist and then 20 for newMaxDist, so it’s not picking up overridden value.

This is how it’s set in FMOD Studio

So as you can see I have overridden max distance for Sneak, but it’s not picking it up in the code.
Am I doing this correctly?

It looks like you have a spatializer on a track that isn’t the master track. The query API cannot see the values of these effects. For details please check the query API documentation. We are aware that the handling of min/max distance isn’t ideal and have plans to improve it for 2.2.

Ok, I see.
I have the Master track defined too.
I just hoped that my override on other tracks will work :slight_smile:

So in v2.2 you plan to add support for overriding max/min distance in some way?

Unfortunately they won’t, only the master track is considered for min/max override and the query APIs.

In 2.2 we will be making min/max a property of the Event rather than a property of a specific panner effect. This means any panner within the event including those on tracks will respond to the min/max Event value. Additionally we will be making min/max at the Event level automatable, so you can expose parameters to control the range just like any other Event property.

1 Like

Thanks for clarifying!
Looking forward for version 2.2 :slight_smile:

Hi Mathew,
I resume this old thread since I’ve also some doubts about setting the min\maxdist through Event Instance Property (can’t use Fmod 2.02 at the moment).
I also get (for example, for min dist using EventInstance->getpropertyt): -1 as minDist value, then I set the minimum distance to let’s say 50 with setProperty, and then I verify that the mindist is effectively changed with the same getProperty (and this time I get 50, as expected).
The problem is that inside the game apparently there is no change in audio even with extreme values…so I am wondering…does this setProperty work also with presets? because I’ve got a spatializer on the main track but it’s a preset shared between multiple events…so maybe no error is logged but the value is not set because it’s a preset?

Thank you very much

P.S: I am using Fmod 2.01 with a proprietary engine…

The key things with 2.01 are only 3D spatializers on the master track are affected by setProperty min / max. Whether that effect is applied directly or via a preset to the Event shouldn’t make any difference. If you min distance is larger than your max distance you might get some weird results, but otherwise it should apply.

Can you perform a simple test setting the min distance to 1000, then placing the Event 900 units away, it should still be fully audible.