Spatialising 2D UI sounds in a 3D game

I’m working on a 3D game, and FMOD Studio is working well for it so far. I use 3D spatialised sounds for the 3D world, and 2D sounds for our UI elements and HUD which are drawn on top.

What I’d like to do is to localise those 2D UI sounds, so that (for example) a window opening on the right side of the screen will play the ‘opening window’ sound effect from the right speakers, without caring where the 3D camera is located/facing in the 3D game world.

Is there a nice, clean way to do this? I can’t see a way to (for example) set the level of pan on an individual 2D sound instance through the API, but maybe I’m just missing something obvious. Is the idea that I need to project the 2D UI position into a camera-relative 3D position and put a 3D spatialiser on all the UI sounds?

Thanks for any advice folks can offer!

There’s two main ways to handle this behavior with the Studio API.

The first is to drive it using an FMOD Spatializer (or any other kind of Spatializer). To do this, you’ll ultimately need to provide FMOD with attributes that “place” the event instance in the desired listener-relative position.

The second is to use a parameter to automate the panning of an event instance. This can be done using a panner on an event’s master audio track, a panner effect, or in the case of a spatializer, the 2D Pan Mix’s panner. You can then calculate the appropriate parameter value for a UI element in game, and set its value on the corresponding event instance.

The main differences between these two options, besides the difference in calculating the position/parameter value, is the additional effects of spatialization which may or may not be desired - i.e. distance attenuation, any additional effects that may be provided by the object spatializer and/or 3rd-party spatializers like HRTF, propagation, etc. Depending on the spatializer, you may be able to disable some of these effects.

In either case, you will likely want to make use of FMOD Studio’s Event Defaults or Preset Effects functionality to more easily apply the desired behavior to multiple events.