Playing attached one-shots with "labeled" parameters

#1

I’m new to FMOD and currently trying out version 2.0.
I was looking for a way to pack all of a character’s voices into a single event, so it wouldn’t become such a mess in the code. Completely by accident, I stumbled upon “labeled parameters” which seem to be tailor-made for this purpose.
However, I haven’t been able to change the values of the parameter in the code, and there seem to be no examples available online. This is how I tried to do it:
(“fmCharacterVoice” is a public reference to an Event Emitter component on a GameObject, because I don’t know how else to avoid having to use strings.)

fmCharacterVoice.EventInstance.setParameterByID(fmCharacterVoiceParamId, 2.0f);
fmCharacterVoice.Play();

No matter what float I set for the parameter, it always plays the first label in the event.

EDIT:
After some experimenting, I realized that everything works fine if I just switch the two lines of code, and start playing the event BEFORE I set the parameter. Surely that’s not intentional. Why can I only change the label during playback?

0 Likes

#2

The setParameterByID should be returning an error, because at that point the EventInstance has not been created. Once Play() is called the EventInstance is created and started.

Otherwise if you don’t need to use the StudioEventEmitter, you will be able to have more control over your events by creating them manually.
https://fmod.com/resources/documentation-unity?version=2.0&page=examples-basic.html

0 Likes