[Unity Visual Scripting] Cannot change emitter's instance after the reference has changed

I cannot figure out how to play more than 2 events with a Studio Event Emitter in my Script Graph:

I can set the reference and it updates that, I can see it in the inspector. But nothing I do can set this emitter’s Event Instance to anything.

I stopped, released it, then set the reference like normal, didn’t work.
I turned the component off, set the reference, then turned it back on again, didn’t work.
I tried releasing after setting the reference, didn’t work.
I tried manually creating an instance, it gave a warning saying EventInstance.set3DAttributes() wasn’t called yet, and also didn’t set the instance anyway.
I stopped, released, set reference, cleared handle, didn’t work.
I stopped, set reference, released, cleared handle, didn’t work.
I stopped, set reference, cleared handle, didn’t work

Hi,

Thank you for sharing the information!

Could you please share a screenshot of your current Script Graph? That’ll help confirm the node order and settings.

Changing the event reference on a Studio Event Emitter won’t swap what’s already playing. The emitter only creates an instance once, and then keeps reusing it, which means just changing the reference field won’t do anything.

If you want to play different events, or have multiple running at the same time, the easier path is to skip the emitter and use event instance nodes instead. That way you can spawn new sounds whenever you like and have full control.

That’s expected when you create a 3D instance manually but don’t attach/set its 3D data. Here’s n example of playing 3d sound via visual scripting.

Here’s a picture of a version that tries the basic method of swapping events, and in the same image (because of the New User perk: “Nuh-uh-uh! One image at a time!”) what gets called on start, it plays the same emitter from that variable:

Aside from an unrelated oneshot, it doesn’t do anything else with FMOD, which is good because that whole Script Graph is literally too big to take a reasonable screenshot of.

  • I wanted to do it for consistency of every other character (they don’t use Visual Scripting)
  • There’s an outside C# script that does basic lip-syncing using that emitter, and I don’t want to make it work with instances, especially since it’s a generic script for other scenarios than this.

Oh yeah, the reason this is the only character that does this is because it’s for the beginning of the game, and it’s way easier to make the whole sequence. I think I’ve gone too far in to turn the Script Graph into C#

I actually don’t know what I was trying to do at this point I think I was desperate

Thank you for sharing the screenshots, it’s super helpful!

The built-in StudioEventEmitter is designed as a simple “one-event player.” It caches the event description the first time you play it, and it won’t refresh if you change the EventReference during runtime.

A similar discussion can be found here: Changing a SudioEventEmitter's Event During Runtime - #2 by Leah_FMOD

If you need to swap events at runtime, you could consider using an extended version of the emitter, for example:

using FMODUnity;

public class StudioEventEmitterEx : StudioEventEmitter
{
    /// <summary>
    /// Change the event at runtime and refresh the cached description.
    /// </summary>
    public void SetEventAndRefresh(EventReference newEventRef)
    {
        // Stop current instance immediately
        AllowFadeout = false;
        Stop();

        // Assign new event
        EventReference = newEventRef;

        // Clear the cached description so next Play() will do Lookup()
        if (eventDescription.isValid())
        {
            eventDescription.clearHandle();
        }
    }
}

This adds a method that clears the cached description and refreshes the reference, so calling it before Play() ensures the new event is used.

Since you’re using Visual Scripting, you may need to run FMOD > Generate Visual Scripting Units again for the new method to appear.

Here’s an example graph:

Hope this helps! Let me know if you have questions.

1 Like

Works exactly as intended
:ok_hand: