# How to Update the Playback Position of Sound for a Continuously Moving Object

**URL:** https://qa.fmod.com/t/how-to-update-the-playback-position-of-sound-for-a-continuously-moving-object/22698
**Category:** Unity
**Created:** [March 15, 2025, 3:43pm UTC](https://qa.fmod.com/t/how-to-update-the-playback-position-of-sound-for-a-continuously-moving-object/22698 "2025-03-15T15:43:21Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![twocomet](https://avatars.discourse-cdn.com/v4/letter/t/ed8c4c/32.png) [@twocomet](https://qa.fmod.com/u/twocomet)
#### Post date: [March 15, 2025, 3:43pm UTC](https://qa.fmod.com/t/how-to-update-the-playback-position-of-sound-for-a-continuously-moving-object/22698/1 "2025-03-15T15:43:21Z")

</div>

Currently, when attempting 3D playback, the sound is heard correctly with 3D spatial effects at the position where playback starts.  
However, if the object playing the sound moves, the playback position does not update accordingly.

Is it possible to set a target object or parent object as the origin point for sound propagation before playing a specific sound?  
If a long sound is playing while the object moves, the playback position should update to reflect the new location.  
For example, consider a music box attached to a horse that is moving around a village.

If this functionality is possible, could you provide an example code?

---

<div class="post-metadata">

### Author: ![li\_fmod](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/li_fmod/32/6577_2.png) [@li\_fmod](https://qa.fmod.com/u/li_fmod)
#### Post date: [March 20, 2025, 2:01am UTC](https://qa.fmod.com/t/how-to-update-the-playback-position-of-sound-for-a-continuously-moving-object/22698/2 "2025-03-20T02:01:51Z")

</div>

Hi, thank you for sharing the information.

> [@twocomet](#):
>
> However, if the object playing the sound moves, the playback position does not update accordingly.

How are you currently play the sound? Are you using your own code, or are you using `FMOD Studio Event Emitter` component to play the sound?

> [@twocomet](#):
>
> Is it possible to set a target object or parent object as the origin point for sound propagation before playing a specific sound?

Yes, it is possible to dynamically update a sound’s position during playback so that it follows the movement of its associated object. You could consider using [AttachInstanceToGameObject](https://www.fmod.com/docs/2.02/unity/api-runtimemanager.html#attachinstancetogameobject) to attach the event instance to the target GameObject.

Here is an example script that you can attach to your moving object:

```auto
using FMODUnity;
using UnityEngine;

public class MovingSound : MonoBehaviour
{
    public EventReference fmodEvent;

    private FMOD.Studio.EventInstance eventInstance;

    void Start()
    {
        // Create the EventInstance
        eventInstance = FMODUnity.RuntimeManager.CreateInstance(fmodEvent);

        // Attach the EventInstance to this GameObject
        FMODUnity.RuntimeManager.AttachInstanceToGameObject(eventInstance, transform, GetComponent<Rigidbody>());

        // Start playback
        eventInstance.start();
    }

    void OnDestroy()
    {
        // Stop and release the EventInstance when the GameObject is destroyed
        eventInstance.stop(FMOD.Studio.STOP_MODE.ALLOWFADEOUT);
        eventInstance.release();
    }
}

```

Hope this helps! Let me know if the issue persists.
