How to change parameter values with switch index scene load system

(Mitch) #1

We are using a switch index to handle all of our BG music and Ambient SFX. The initial start event and parameter set works fine, but when we try and change the parameter’s value in the next case in the switch index, it says the parameter variable is unassigned. If we reassign it in each case then it says that that variable has already been assigned in this source. Very perplexing indeed. Essentially, I want to be able to change parameters on an event throughout different cases (scene loads). Here is what I have now.

It plays the windSFX just fine and sets it’s parameter to 1. I want to set it back to 0 in the next scene ( case 1: ) any ideas on how to reference the parameter string across cases?

enter image description here

here is a direct link to the image in dropbox

(Cameron Baron) #2

The issue you are facing is to do with scope. Cases don’t know about other cases, they only know about itself and any class level variables.

You can start with an event instance and a parameter instance outside the switch and use/reassign them as needed.

FMOD.Studio.EventInstance foo;
FMOD.Studio.ParameterInstance bar;
void Function()

    case 0:
        foo = FMODUnity.RuntimeManager.CreateInstance("eventName");
        foo.getParameter("paramName", bar);
    } break;

    case 1:
    } break;


(Mitch) #3

Hey Cameron,
Thanks a lot for the reply. I’m a composer by trade and am really trying to step away from using designer based components and get a solid grasp on coding my audio implementation. I’ll get to work with your input tomorrow! Thanks again,