I’ve been confused with event emitter for a while now in regards to this. If you’ve played from a StudioEventEmitter
and then after that StudioEventEmitter.Stop()
is called before StudioEventEmitter.IsPlaying()
within the same frame, for some reason StudioEventEmitter.IsPlaying()
returns true?
Is there something I’m misunderstanding about how stopping works? Is there a better way to completely reset the state of an event emitter before hitting play again?
Hi,
The Stop() function utilizes the current Allow Fadeout When Stopping
value assigned in the emitter’s Advanced Controls
:
![image](https://global.discourse-cdn.com/standard10/uploads/fmod/original/2X/3/35fab056becd5409baff7207e70c676fda497458.png)
IsPlaying()
may return true because the event is still fading out. If you have Allow Fadeout
enabled, could you please try disabling it and let me know if the issue persists?
As an alternative, consider using Studio::EventInstance::getPlaybackState(). This function provides a more detailed state of the event instance. Here’s an example to check the current state:
Check current state example
public FMODUnity.StudioEventEmitter emitter;
private FMOD.Studio.PLAYBACK_STATE currentState = FMOD.Studio.PLAYBACK_STATE.STOPPED;
// Update is called once per frame
void Update()
{
emitter.EventInstance.getPlaybackState(out currentState);
Debug.Log($"Instance state is: {currentState}");
if (Input.GetKeyDown(KeyCode.Escape))
{
emitter.Stop();
}
if (Input.GetKeyUp(KeyCode.Space))
{
emitter.Play();
}
}
Disabling the Allow Fadeout
option should immediately return true from IsPlaying()
. However, if you prefer to keep fadeout enabled for your events, using getPlaybackState()
might be a better solution.
Hope this helps