Prevent Retriggering of Sound During Parameter Change

Hey all, so I have an event in a Unity project that plays a certain weapon firing sound based on the current Timeline bar of another event playing a background music track. The weapon firing event is played using PlayOneShot whenever a button is pressed (using Input.GetKey). I am using Timeline callbacks to send the bar number of the music event to a global discrete SongBar parameter, which will then determine the sound to use from the parameter sheet of the weapon firing event . It works well until the parameter is changed in the middle of the event playing (changes from one bar to the next). If the event is triggered just before the transition, it will play the sound that corresponds with the current bar, then immediately the next bar, resulting in two sounds triggering from a single button press. I am still learning FMOD, Unity, and C# scripting in general, so I feel like I am missing something that should be obvious.

I recommend you use a held local parameter inside the event that plays the weapon firing sound. To make a parameter held, open the edit parameter dialog, and ensure the “Hold value during playback” checkbox is checked.

Held parameters don’t change in value while the event instance is playing, so changes to a held parameter’s value won’t cause instruments on that parameter to trigger or retrigger.

Of course, you’ll have to set the value of the parameter before the event instance starts playing. One of the easiest ways to do this is to nest the event inside another event, and automate the event instrument’s parameter value on the global parameter you already have.

Hey Joseph, thank you so much for your reply! I am little confused about automating the local parameter with the global one, though. Would both parameters be a “SongBar” parameter, where the global one is being updated through my Timeline callback code, and then the local one would just follow it exactly?
Here are screens of my event at the moment.

Thanks again for your help

If you select your “note” event instrument, you should see its parameter knob in the deck. You can right-click on this knob to add automation to it. This automates the value of the nested event’s parameter based on the value of the parameter it’s automated on in the parent event.

The name of the nested event’s parameter doesn’t have to match that of the global parameter. In fact, it’s probably less confusing if it has a different name. They have to be two different parameters in any case, as the local parameter must be held and the global parameter not held.

Thanks so much, got it working!