# Pan for 2d game

**URL:** <https://qa.fmod.com/t/pan-for-2d-game/16219>\
**Category:** FMOD Engine\
**Created:** [September 24, 2020, 2:13pm UTC](https://qa.fmod.com/t/pan-for-2d-game/16219 "2020-09-24T14:13:27Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![rsa](https://avatars.discourse-cdn.com/v4/letter/r/839c29/32.png) [@rsa](https://qa.fmod.com/u/rsa)\
**Post date:** [September 24, 2020, 2:13pm UTC](https://qa.fmod.com/t/pan-for-2d-game/16219/1 "2020-09-24T14:13:27Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![mathew](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/mathew/32/431_2.png) [@mathew](https://qa.fmod.com/u/mathew)\
**Post date:** [September 25, 2020, 1:34am UTC](https://qa.fmod.com/t/pan-for-2d-game/16219/2 "2020-09-25T01:34:45Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![rsa](https://avatars.discourse-cdn.com/v4/letter/r/839c29/32.png) [@rsa](https://qa.fmod.com/u/rsa)\
**Post date:** [September 25, 2020, 11:36am UTC](https://qa.fmod.com/t/pan-for-2d-game/16219/3 "2020-09-25T11:36:38Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![mathew](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/mathew/32/431_2.png) [@mathew](https://qa.fmod.com/u/mathew)\
**Post date:** [September 27, 2020, 11:13pm UTC](https://qa.fmod.com/t/pan-for-2d-game/16219/4 "2020-09-27T23:13:12Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![rsa](https://avatars.discourse-cdn.com/v4/letter/r/839c29/32.png) [@rsa](https://qa.fmod.com/u/rsa)\
**Post date:** [September 28, 2020, 12:34pm UTC](https://qa.fmod.com/t/pan-for-2d-game/16219/5 "2020-09-28T12:34:09Z")

</div>

@mathew thank you for your help!
