Pan for 2d game

In a 2D game I don’t need the distance attenuation / panning of 3D sound; I just want to set the left/right pan of the sfx’s. At the moment I am using a constant 3D_Attributes for the listener and all the sources of the sfx:

FMOD_3D_ATTRIBUTE = fmod._3D_ATTRIBUTES()
FMOD_3D_ATTRIBUTE.position = ZERO
FMOD_3D_ATTRIBUTE.velocity = ZERO
FMOD_3D_ATTRIBUTE.forward = FORWARD
FMOD_3D_ATTRIBUTE.up = UP

(This is lua for fmod-Defold.)

Then in FMOD Studio I have created a Pan parameter (with range -1, +1) and I have added a automation to the pan property of each sfx I want to pan; this automation is just a linear interpolation from (-1, +1) to (-100, +100). So I create a sfx with something similar to

local event_description = fmod.studio.system:get_event(name)
local event = event_description:create_instance()
event:set_3d_attributes(FMOD_3D_ATTRIBUTE)
event:set_parameter_by_name("Pan", pan, true)
event:start()

Is this the right way to exclude the 3D attenuation / panning and implement a simple left/right pan? Is there some simpler way? I may guess that the attenuation/speed/panning computations are being performed anyway by the fmod-runtime just wasting time…

Many thanks for any help!

If you prefer doing panning via pan parameter that’s certainly an option. If you did this you would remove the 3D spatializer from the Event in FMOD Studio (you don’t need it). You also don’t need to set the 3D attributes for Events that don’t have spatializers either. Even the listener attributes can be ignored if everything is 2D.

Hey @mathew, thank you so much for your reply!

No 3D spazializer! Yes, I understand!

So I need a unique parameter “Pan” and FOR EACH sfx an Automation of the pan property with a linear interpolating curve. Or is there a way to add the automation to all events at the same time? (But, of course, I need to have different Pan values in runtime for each event!)

Thanks again!

Yes you are correct.

To simplify doing this I would suggest creating a preset effect that wraps up the panner (available as an effect in 2.1) and the automation / parameter. Then you can bulk edit (select all) events you want to apply it to and do it in one go.

@mathew thank you for your help!