# Runtime get spacial distance

**URL:** <https://qa.fmod.com/t/runtime-get-spacial-distance/17482>\
**Category:** Unity\
**Tags:** unity, csharp\
**Created:** [July 27, 2021, 9:11am UTC](https://qa.fmod.com/t/runtime-get-spacial-distance/17482 "2021-07-27T09:11:35Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mapster](https://avatars.discourse-cdn.com/v4/letter/m/50afbb/32.png) [@Mapster](https://qa.fmod.com/u/Mapster)\
**Post date:** [July 27, 2021, 9:11am UTC](https://qa.fmod.com/t/runtime-get-spacial-distance/17482/1 "2021-07-27T09:11:35Z")

</div>

Hello

Is there a way to get the spacial distance of an instance at runtime?

I’m using it to check if the player can hear a sound or not.

Cheers

---

<div class="post-metadata">

**Author:** ![Alcibiade](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/alcibiade/32/4284_2.png) [@Alcibiade](https://qa.fmod.com/u/Alcibiade)\
**Post date:** [July 27, 2021, 12:34pm UTC](https://qa.fmod.com/t/runtime-get-spacial-distance/17482/2 "2021-07-27T12:34:44Z")

</div>

Do you want to retrieve that info within Unity or FMOD? If FMOD, you should create a new parameter and choose type “built-in: distance”. If so, for which purpose do you want to implement that logic in FMOD?

---

<div class="post-metadata">

**Author:** ![Mapster](https://avatars.discourse-cdn.com/v4/letter/m/50afbb/32.png) [@Mapster](https://qa.fmod.com/u/Mapster)\
**Post date:** [July 27, 2021, 12:47pm UTC](https://qa.fmod.com/t/runtime-get-spacial-distance/17482/3 "2021-07-27T12:47:14Z")

</div>

I want to retrieve it in Unity. Ideally without having to add a parameter and adjust it everytime the spacial min & max distance changes.

Or if there is a way to check if a sound can be heard by a listener somehow that could also work.

---

<div class="post-metadata">

**Author:** ![Alcibiade](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/alcibiade/32/4284_2.png) [@Alcibiade](https://qa.fmod.com/u/Alcibiade)\
**Post date:** [July 27, 2021, 12:57pm UTC](https://qa.fmod.com/t/runtime-get-spacial-distance/17482/4 "2021-07-27T12:57:18Z")

</div>

The parameter I were talking about hasn’t to be ajusted, it’s a special parameter that retrieves in real time some infos (here the distance) the engine has on that object. The value of this built-in parameter can be used to parameterize or condition some other things in FMOD.

But if you want to retrieve that info in Unity, I can’t tell (I’m more on the UE4 side) but I’m pretty much certain it’s a very basic question. You just have to check the distance between the object the FMOD instance is attached to, and the player (or the camera). Why don’t you rather ask on a Unity forum, since your question isn’t in fact related to FMOD?

---

<div class="post-metadata">

**Author:** ![Mapster](https://avatars.discourse-cdn.com/v4/letter/m/50afbb/32.png) [@Mapster](https://qa.fmod.com/u/Mapster)\
**Post date:** [July 27, 2021, 1:07pm UTC](https://qa.fmod.com/t/runtime-get-spacial-distance/17482/5 "2021-07-27T13:07:23Z")

</div>

Ah the issue was because I couldn’t get the min/max distance that the event could be heard by a listener.

I tried the below code and it works but last time I tried it didn’t work so maybe was a bug and fixed in a previous version of FMOD.

> instance.getDescription(out m\_description);  
> m\_description.getMinimumDistance(out m\_minDistance);  
> m\_description.getMaximumDistance(out m\_maxDistance);

Thanks anyway! 😀

---

<div class="post-metadata">

**Author:** ![Alcibiade](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/alcibiade/32/4284_2.png) [@Alcibiade](https://qa.fmod.com/u/Alcibiade)\
**Post date:** [July 27, 2021, 1:20pm UTC](https://qa.fmod.com/t/runtime-get-spacial-distance/17482/6 "2021-07-27T13:20:35Z")

</div>

Ok, your first question wasn’t clear, you said you wanted to retrieve the distance, but it seems you rather wanted to retrieve in Unity the min/max distance set in FMOD event spatializer.  
The spatializer has been changed in 2.02, maybe that could explain. [https://www.fmod.com/resources/documentation-studio?version=2.02&page=welcome-to-fmod-studio-new-in-202.html#event-min-max-distance](https://www.fmod.com/resources/documentation-studio?version=2.02&page=welcome-to-fmod-studio-new-in-202.html#event-min-max-distance)  
I’m glad it eventually works!
