Triggering sustain or cue, Unity C#, FMOD Studio

Another pro-tip here collected from a lot of searching:

To trigger ANY cue on an event created in FMOD Studio and refernced with C# in unity, you have to work around two weird things:

First, all cues are called “KeyOFF”. So don’t go around trying to get cue “A”, because it’s called “KeyOFF”.

SECOND, cue.trigger() does not exist, and harks back to a c++ typo from 2008 somehow. To trigger your cue, you must instead call cue.setValue(float), which doesn’t set any value and disregards that value and is actually going to trigger your cue.

So, if “zoom” is your EventInstance

FMOD.Studio.CueInstance cue;
zoom.getCue("KeyOFF",out cue);
if ( cue!=null ) {   //not needed check, but prolly a good idea
    cue.setValue(0f);
}

You have successfully triggered Cue A.

nice! my version didn’t have this function for some reason.

A quick note here…

I have just needed to do exactly this, trigger a cue. Using FMOD 1.03.01 it seems that - cue.setValue(0f); - does NOT trigger the cue for me (gives error).

Instead, I used - cue.trigger(); - and it works.

I haven’t got so far yet, but thanks for sharing, knowing this could save a lot of time and headaches!

the method setValue doesn’t exist anymore, I used trigger() as said above but this didn’t do anything. Is there anything more that needs to be done??

This is my code:

FMOD.Studio.CueInstance cue;

var pauseEvent = FMOD_StudioSystem.instance.GetEvent(“event:/”+ResourceData.PAUSE_SOUND);

pauseEvent.getCue(“KeyOFF”, out cue);

if (cue != null)
{
cue.trigger();
}

Did anyone ever solve this issue? I am having the same issue as João.

1 Like

CueInstance.trigger() is part of the API now. The Cue (there is only ever 0 or 1) is still always called “KeyOFF”.

Apologies, the issue for me here was that the event was looped in FMOD Studio. Removing the loop section fixed the issue. Interestingly, the loop didn’t apply to the event in FMOD Studio, but instead prevented the event from continuing when trigger() was called in engine.