# How to get spatializer min/max distance override in code (FMOD 2.02.03)

**URL:** <https://qa.fmod.com/t/how-to-get-spatializer-min-max-distance-override-in-code-fmod-2-02-03/17913>\
**Category:** Unity\
**Tags:** csharp\
**Created:** [November 5, 2021, 6:26pm UTC](https://qa.fmod.com/t/how-to-get-spatializer-min-max-distance-override-in-code-fmod-2-02-03/17913 "2021-11-05T18:26:58Z")\
**Posts on this page:** 1\
**Showing post:** 8

<div class="post-metadata">

**Author:** ![jeff\_fmod](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/jeff_fmod/32/1766_2.png) [@jeff\_fmod](https://qa.fmod.com/u/jeff_fmod)\
**Post date:** [November 24, 2021, 11:10pm UTC](https://qa.fmod.com/t/how-to-get-spatializer-min-max-distance-override-in-code-fmod-2-02-03/17913/8 "2021-11-24T23:10:40Z")

</div>

Apologies for the oversight there, you are right the non-linearity of the spatializer makes it impractical to use parameters effectively for this purpose.  
In that case, I think a script might be the best way to go.  
Here is a simple script for replacing the event macro min and max distances with the min and max distances on the spatializer in the master track. Run it before building and it should be a good workaround. Place it in your FMOD plugins directory and it should be a good starting point for you:

```auto
studio.menu.addMenuItem({ name: "Transfer Event Min Max",
    isEnabled: function() { var event = studio.window.browserCurrent(); return event && event.isOfExactType("Event"); },
    execute: function() {

        function transferSpatializerMinMaxValues(event)
        {
            var effects = event.masterTrack.mixerGroup.effectChain.effects;

            effects.forEach(function(effect) {
                if(effect.entity == "SpatialiserEffect") {
                    event.automatableProperties.minimumDistance = effect.minimumDistance;
                    event.automatableProperties.maximumDistance = effect.maximumDistance;
                    return;
                }
            });

        }

        var events = studio.project.model.Event.findInstances();
        events.forEach(function(event) {
            transferSpatializerMinMaxValues(event);
        });

    },
});

```

Then you can just read the min and max values from the event description as usual:

```auto
emitter = GetComponent<FMODUnity.StudioEventEmitter>();

var eventDescription = FMODUnity.RuntimeManager.GetEventDescription(emitter.EventReference);
eventDescription.getMinMaxDistance(out float min, out float max);
Debug.Log(String.Format("Min: {0}, Max: {1}", min, max));

```

---

_[View the full topic](https://qa.fmod.com/t/how-to-get-spatializer-min-max-distance-override-in-code-fmod-2-02-03/17913)._
