Runtime get spacial distance


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.


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?

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.

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?

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! :grinning:

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.
I’m glad it eventually works!