How do I change the event in FMOD Studio Event Emitter through C#? It keeps playing the same previous event

So I’m making an action rpg in which I’d like to have interactable music with the player. Essentially we have our sound track set up with multiple loops that have parameters to slowly add them. With triggers in the scene the loops slowly get added on when the Studio Event Emitter. So when I transition into another scene, I thought it’d be pretty simple to change the Event by changing the string. So I create a script to manage the music, had it grab the Studio Event Emitter on the player, called Stop(), changed the path, then called Play().

The issue is this doesn’t work. Once I transition between scenes it will stop but will play the same previous event instead of the updated event. I figured maybe I had to call something in the Event Emitter to refresh it, but when I debugged the emitter it would be using the new path all the way up to Instance.Start(). LookUp() seems to call to change the eventDescription with the new path, and it creates an instance from this new path. So my question is, why isn’t this new path working? Is there something I need to change? Something I need to add to my code? Please help me, I’ve looked through a ton of forums and couldn’t find any related issues or answers.

I ended up finding a solution, but I don’t like how not pretty it is as I had to mess around with the code with Studio Event Emitter.

In the Studio Event Emitter, I went into the Play() method and added:
If(hasTriggered)
{
LookUp();
}

The issue was that essentially the eventDescription was not being updated even though the string had changed because the LookUp() method only played when the eventDiscription was not valid. It’s pretty annoying how hard it was just to change an event between scenes, I would’ve though there would have been an easier method for this. Oh well.

1 Like

It looks like what you have done is currently the only way to re-use a StudioEventEmitter, although this should be easy to fix.

My first thought would be to expose a function that takes a string, the new event, and updates the event description. Because doing too many things in Play() can cause undesirable delays, more noticeable on some platforms.

public void ChangeEvent(string newEvent)
{
Event = newEvent;
instance.Stop();
Lookup();
}

This is only an initial thought and would require further testing, but it should do the job for now.

1 Like

I think FMOD should definitely fix this issue since it’s quite common to re-use SEE and it makes zero sense to create a new instance every time.

I am facing the same issue, strange that this has not been fixed already ?

@vbilot Technically it has been fixed by either adding either the method @cameron-fmod or I discussed. Open up the script for Student Event Emitter and add ChangeEvent() method into the script. Now when you want to change the event, call that method first and then play.

I don’t know about any official fixes though.

Yes I was talking about official fixes, I did change the EventEmitter script and worked well.

Thank you for answering so fast tho !

1 Like

After a lot of internal discussion, we came to the conclusion that this was not the ideal way to use the StudioEventEmitters. Originally the included scripts were intended to be examples for people to use when creating their own scripts, but over time more and more functionality has been added to them.

Creating your own scripts will give you the freedom pick out the behavior that you want to use and leave out anything you don’t need, making the scripts more efficient.

Ok thanks for the answer :slight_smile: