Cant change event parameter


i cant change the parameter of a simple sound with FMOD. Iam new in fmod and trying to move my project into the FMOD space.

I created an FMOD Event Emitter and attached an event to it. The Event has an integer parameter which will change the used sounds.

iam trying to access the integer value like this:

        playerController.playerCore.m_eventEmitter.SetParameter("Terrain", 1);

It always stays at “0” so it plays concrete footstep sounds. while 1 should be the wooden sound. When iam in unity and get onto the event with the event browser, everything works flawless.

How can i adjust the parameter via script?

When i change the slider manually it works. Even why i try to use the parameter script the changes wont take effect. iam using unity 2019.4.40f lts

EDIT: I tried to catch the value with:

                    emitterRef.Target.EventInstance.getParameterByName("Terrain", out float value);
                        Debug.Log("Triggered: " + value);

and its showing the correct value, but the sound isnt changing. This seems strange…


Thank you for your time.


You were super close to getting it right. The problem is you are trying to set the parameter on an event instance that hasn’t been created yet.

The StudioEventEmitter.Play() function creates and plays a new instance of the event. A deeper explanation of Event Instances is under Glossary | Event Instance.

To solve the problem change the Play() and SetParameter() positions like this:


playerController.playerCore.m_eventEmitter.SetParameter("Terrain", 1);

No we are creating a new instance of the event, then setting the Terrain parameter.

Hope this helps!