# Set Mode 2D/3D Errors

**URL:** <https://qa.fmod.com/t/set-mode-2d-3d-errors/18684>\
**Category:** Unity\
**Created:** [April 20, 2022, 3:21pm UTC](https://qa.fmod.com/t/set-mode-2d-3d-errors/18684 "2022-04-20T15:21:42Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![martindevans1](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/martindevans1/32/3052_2.png) [@martindevans1](https://qa.fmod.com/u/martindevans1)\
**Post date:** [April 20, 2022, 3:21pm UTC](https://qa.fmod.com/t/set-mode-2d-3d-errors/18684/1 "2022-04-20T15:21:43Z")

</div>

I’m playing back sound through FMOD which I want to switch from 2D/3D mode on the fly. To do that I’ve got some code like this:

```csharp
// Nb. `_channel` is an `FMOD.Channel`

if (positional)
{

    Check(_channel.setMode(MODE._3D | (MODE)RolloffMode), "Failed `setMode`", true);
    Check(_channel.set3DMinMaxDistance(MinDistance, MaxDistance), "Failed `set3DMinMaxDistance`", true);
}
else
{
    Check(_channel.setMode(MODE._2D), "Failed `setMode`", true); // <-- ERROR HERE!
}

```

However, when I run this I’m getting errors on the final line:

> Failed `setMode`. FMOD Result: ERR\_NEEDS3D

This appears to be telling me that I simply _cannot_ set this channel into 2D mode! What am I doing wrong here?

Edit: I’m calling this every frame. So is the problem that I’m calling `_channel.setMode(MODE._2D)` on a channel which is _already_ 2D?

---

<div class="post-metadata">

**Author:** ![jeff\_fmod](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/jeff_fmod/32/1766_2.png) [@jeff\_fmod](https://qa.fmod.com/u/jeff_fmod)\
**Post date:** [April 26, 2022, 12:52am UTC](https://qa.fmod.com/t/set-mode-2d-3d-errors/18684/2 "2022-04-26T00:52:03Z")

</div>

You should be able to set the mode of a channel at runtime, what version of FMOD are you using?  
Are you playing these channels using the Core API, via `System.createSound`, or the Studio API, creating events and getting their channels using `EventInstance.getChannelGroup`? If you are using the Studio API you can try toggling the byppass state of the spatializer (“FMOD Pan” dsp):

```auto
void Toggle2D3D(FMOD.Studio.EventInstance eventInstance)
{
    eventInstance.getChannelGroup(out FMOD.ChannelGroup cg);
    cg.getNumDSPs(out int numDSPs);

    // Linear search for spatializer
    for(int i = 0; i < numDSPs; ++i)
    {
        cg.getDSP(i, out FMOD.DSP dsp);
        dsp.getInfo(out string dspName, out uint version, out int channels,
            out int configwidth, out int configheight);

        // "FMOD Pan" is the Spatializer DSP setup in Studio
        if (dspName.Contains("FMOD Pan"))
        {
            dsp.getBypass(out bool bypassed);
            dsp.setBypass(!bypassed);
        }
    }
}

```
