# StudioListener.cs should fetch Rigidbody from parent

**URL:** <https://qa.fmod.com/t/studiolistener-cs-should-fetch-rigidbody-from-parent/23283>\
**Category:** Unity\
**Tags:** unity, csharp\
**Created:** [August 28, 2025, 8:46am UTC](https://qa.fmod.com/t/studiolistener-cs-should-fetch-rigidbody-from-parent/23283 "2025-08-28T08:46:24Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![edvinas108](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/edvinas108/32/7948_2.png) [@edvinas108](https://qa.fmod.com/u/edvinas108)\
**Post date:** [August 28, 2025, 8:46am UTC](https://qa.fmod.com/t/studiolistener-cs-should-fetch-rigidbody-from-parent/23283/1 "2025-08-28T08:46:24Z")

</div>

When using `StudioListener.cs`in my games, I always drop it onto the `Camera` object which usually sits under the `Rigidbody `component of the player object. Form my personal experience, I found that this is the most common way to structure a “player” in Unity games. Additionally, it seems that this is the preferred way as Unity places it’s own listener component on the camera object.

To better illustrate the hierarchy I’m talking about:

```plaintext
Player (rigidbody, gameplay components)
|
+-- Head (camera, listener)
+-- HUD (UI)
+-- VFX (particles, etc)
+-- SFX (audio emitters related to player)
+-- Body (3D stuff)

```

Today an audio engineer from our team noted, that built-in parameters, such as [distance](https://www.fmod.com/docs/2.00/studio/parameters-reference.html#distance) were not working for spatial audio. I was confused initially as we we’re passing 3D parameters via `RuntimeManager.AttachInstanceToGameObject`in our SFX. Then I looked into the code that ships with Unity FMOD and noticed that `StudioListener.cs`uses `gameObject.GetComponent<Rigidbody>()`and does no additional checks to test if the listener is under a `Rigidbody`. Due to this, using the structure I showcased the listener does not attach to a `Rigidbody`and the built-in parameters fail silently in FMOD.

My suggestion would be to use `gameObject.GetComponentInParent<Rigidbody2D>()` in `StudioListener.cs`instead of `gameObject.GetComponent<Rigidbody>()`. This way it’ll still work for users who place listener components on Rigidbodies as `GetComponentInParent` first checks the owning game object, but it’ll also cover the cases as I’ve shown. Alternatively `private Rigidbody rigidBody;` should be serialized to allow specifying it manually.

---

<div class="post-metadata">

**Author:** ![cameron-fmod](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/cameron-fmod/32/261_2.png) [@cameron-fmod](https://qa.fmod.com/u/cameron-fmod)\
**Post date:** [September 3, 2025, 6:12am UTC](https://qa.fmod.com/t/studiolistener-cs-should-fetch-rigidbody-from-parent/23283/2 "2025-09-03T06:12:26Z")

</div>

Thanks for the information and suggestion, it does sound like a good idea to use `GetComponentInParent instead of GetComponent` although we only use the rigidbodys to get the velocity for use with doppler. We don’t use the rigidbody for positioning at all, we use the gameobject which the listener is attached to.

> [@edvinas108](#):
>
> Today an audio engineer from our team noted, that built-in parameters, such as [distance](https://www.fmod.com/docs/2.00/studio/parameters-reference.html#distance) were not working for spatial audio.

Can you elaborate on this at all? From my testing, the distance parameter is behaving as expected even when no rigidbody is assigned.

---

<div class="post-metadata">

**Author:** ![edvinas108](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/edvinas108/32/7948_2.png) [@edvinas108](https://qa.fmod.com/u/edvinas108)\
**Post date:** [September 3, 2025, 7:24am UTC](https://qa.fmod.com/t/studiolistener-cs-should-fetch-rigidbody-from-parent/23283/3 "2025-09-03T07:24:54Z")

</div>

You’re correct, if the RigidBody (RB) is `null` Doppler still works, tho I’m referring to built-in parameters which you can access in FMOD. After I made an adjustment to the listener script so it fetches RB from the parent, the audio engineer on our team noted that these parameters started working. I’m not 100% sure if they were referring to `distance` or just linked this param by accident as they we’re trying other parameters during that moment and just copied the link to the header they clicked on. As I’m not working directly in FMOD Studio, I cannot verify which parameter it is exactly, just forwarding my findings from Unity side 😅
