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?
Hi, thank you for sharing the information.
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?
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 to attach the event instance to the target GameObject.
Here is an example script that you can attach to your moving object:
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.