# C# 2D Events

**URL:** <https://qa.fmod.com/t/c-2d-events/14153>\
**Category:** FMOD Engine\
**Created:** [October 21, 2018, 5:22pm UTC](https://qa.fmod.com/t/c-2d-events/14153 "2018-10-21T17:22:03Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sneaky\_Tactician](https://avatars.discourse-cdn.com/v4/letter/s/b77776/32.png) [@Sneaky\_Tactician](https://qa.fmod.com/u/Sneaky_Tactician)\
**Post date:** [October 21, 2018, 5:22pm UTC](https://qa.fmod.com/t/c-2d-events/14153/1 "2018-10-21T17:22:03Z")

</div>

Hi,

I am trying to play 2D FMOD Studio Events via the FMOD API/FMOD Studio API. I need to be able to:

-Play studio events  
-Have sound played reflect the position of the sound played, as well as the player’s current position (surround sound)  
-Support multiple sounds playing at the same time/mixing together

How would I do this via the API, in C#?

---

<div class="post-metadata">

**Author:** ![cameron-fmod](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/cameron-fmod/32/261_2.png) [@cameron-fmod](https://qa.fmod.com/u/cameron-fmod)\
**Post date:** [October 25, 2018, 3:28am UTC](https://qa.fmod.com/t/c-2d-events/14153/2 "2018-10-25T03:28:25Z")

</div>

We have a C# wrapper available either in our Unity Integration or in the API download. It is made to be a direct wrapper for our LowLevel and Studio API’s, allowing you to use them in the same way you would in C++.

We also have examples included in our API downloads, these are in C++ but they can give you an understanding of the workflow. Our documentation includes C++, C, C# and JavaScript syntax for all functions.

---

<div class="post-metadata">

**Author:** ![Sneaky\_Tactician](https://avatars.discourse-cdn.com/v4/letter/s/b77776/32.png) [@Sneaky\_Tactician](https://qa.fmod.com/u/Sneaky_Tactician)\
**Post date:** [October 29, 2018, 10:30pm UTC](https://qa.fmod.com/t/c-2d-events/14153/3 "2018-10-29T22:30:19Z")

</div>

> [@](#):
>
> We have a C# wrapper available either in our Unity Integration or in the API download. It is made to be a direct wrapper for our LowLevel and Studio API’s, allowing you to use them in the same way you would in C++.
> 
> We also have examples included in our API downloads, these are in C++ but they can give you an understanding of the workflow. Our documentation includes C++, C, C# and JavaScript syntax for all functions.

Sorry for the late response, life got busy: I realize this, have been utilizing them, and have even managed to use FMOD for playing normal sound events. Now however, I am trying to play this sound events in a 2D fashion. I have made several attempts at using a “listener”, or an “object spatializer”, but to no avail. Are there any tutorials, code samples, or resources that cover exactly what I am trying to do?

I have searched the internet thoroughly, but could not find any code examples to learn from that use both FMOD events, AND a method of playing the sound at a particular position in 2D.

---

<div class="post-metadata">

**Author:** ![Sneaky\_Tactician](https://avatars.discourse-cdn.com/v4/letter/s/b77776/32.png) [@Sneaky\_Tactician](https://qa.fmod.com/u/Sneaky_Tactician)\
**Post date:** [November 4, 2018, 7:25pm UTC](https://qa.fmod.com/t/c-2d-events/14153/4 "2018-11-04T19:25:54Z")

</div>

Bump

---

<div class="post-metadata">

**Author:** ![cameron-fmod](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/cameron-fmod/32/261_2.png) [@cameron-fmod](https://qa.fmod.com/u/cameron-fmod)\
**Post date:** [November 5, 2018, 3:49am UTC](https://qa.fmod.com/t/c-2d-events/14153/5 "2018-11-05T03:49:25Z")

</div>

Our API downloads come with many different example projects you can use as a guide.

2D sounds normally refers to sounds that aren’t spatialized or have a origin in the world. Eg. Background music or environmental ambience.

3D sounds have a position in the world even in a 2D game, although one plane can be ignored/set to zero.

---

<div class="post-metadata">

**Author:** ![Sneaky\_Tactician](https://avatars.discourse-cdn.com/v4/letter/s/b77776/32.png) [@Sneaky\_Tactician](https://qa.fmod.com/u/Sneaky_Tactician)\
**Post date:** [November 5, 2018, 11:50pm UTC](https://qa.fmod.com/t/c-2d-events/14153/6 "2018-11-05T23:50:52Z")

</div>

Oh, I didn’t know that 2D sound referred to that. I figured it just meant sound with an X & Y position. I’ll have a go at adapting some of the tutorials/samples that I skipped over as I thought they were for 3D only, not positioning with an X & Y. Thanks!

---

<div class="post-metadata">

**Author:** ![Sneaky\_Tactician](https://avatars.discourse-cdn.com/v4/letter/s/b77776/32.png) [@Sneaky\_Tactician](https://qa.fmod.com/u/Sneaky_Tactician)\
**Post date:** [November 10, 2018, 11:35pm UTC](https://qa.fmod.com/t/c-2d-events/14153/7 "2018-11-10T23:35:44Z")

</div>

I now have sound that gets louder and softer when approaching random points in my map (what?).

Here’s what I am using right now to allow for event based sound in a 2D map.

```
    public static void RaiseEvent(string eventPath, string parameterName, int value, Point2D screenPosition)
    {
        _System.getEvent(eventPath, out EventDescription _event);
        _event.createInstance(out EventInstance instance);
        instance.setParameterValue(parameterName, value);

        _3D_ATTRIBUTES D3 = new _3D_ATTRIBUTES();

        FMOD.VECTOR forward = new FMOD.VECTOR();
        forward.x = 1;
        forward.y = 1;
        forward.z = 0;

        FMOD.VECTOR up = new FMOD.VECTOR();
        up.x = 1;
        up.y = 1;
        up.z = -1;

        FMOD.VECTOR position = new FMOD.VECTOR();
        position.x = screenPosition.X;
        position.y = screenPosition.Y;
        position.z = 0;

        D3.forward = forward;
        D3.up = up;
        D3.position = position;

        instance.set3DAttributes(D3);
        instance.start();
    }

```

My listener update call:

```
        _3D_ATTRIBUTES atts = new _3D_ATTRIBUTES();
        atts.forward.x = 1;
        atts.forward.y = 1;
        atts.forward.z = 0;

        Point2D camera = RenderInfo.GetCameraCenter();
        atts.position.x = camera.X;
        atts.position.y = camera.Y;
        atts.position.z = 0;

        atts.up.x = 1;
        atts.up.y = 1;
        atts.up.z = -1;

        System.setListenerAttributes(0, atts);

```

Any suggestions why this doesn’t work correctly?

---

<div class="post-metadata">

**Author:** ![cameron-fmod](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/cameron-fmod/32/261_2.png) [@cameron-fmod](https://qa.fmod.com/u/cameron-fmod)\
**Post date:** [November 13, 2018, 12:14am UTC](https://qa.fmod.com/t/c-2d-events/14153/8 "2018-11-13T00:14:23Z")

</div>

The forward and up vectors must be of unit length (1).  
eg.  
atts.forward.x = 1;  
atts.forward.y = 0;  
atts.forward.z = 0;  
atts.up.x = 0;  
atts.up.y = 1;  
atts.up.z = 0;

[https://fmod.com/resources/documentation-api?page=content/generated/FMOD\_3D\_ATTRIBUTES.html](https://fmod.com/resources/documentation-api?page=content/generated/FMOD_3D_ATTRIBUTES.html)
