Hi, in our project I am trying to start an event that needs to be played whenever an object is moving. The problem is that when I check for the event if it is already playing it never returns the FMOD_EVENT_STATE_PLAYING. The result is always FMOD_EVENT_STATE_READY. This is the code I use to start playing an event. Thanks
[code:2cl5adyo]void FW::EventProject::EventStart(const char * a_Name)
FMOD::Event * event = this->GetEvent(a_Name);
event->getState( &state );
if ( !( state & FMOD_EVENT_STATE_PLAYING ) )
- Spkka asked 7 years ago
It’s been a while since I’ve used the Event system, but I think that what’s happening is that the getEvent() call is actually getting a new Event (and possibly stealing existing playing events), not getting the Event data. This behavior is actually documented in the CHM for getEvent():
[quote:ezg2xa1m]- If you call this function more times than there are event instances, then an event handle may be stolen, or may fail. This behaviour also determined by the sound designer.[/quote:ezg2xa1m]
To solve your particular problem, you can either cache the Event* that you used to start the sound, or you can get an info-only Event (with FMOD_EVENT_INFOONLY), then use Event::getInfo() to find the playing Events, and query them that way.
I would suggest the former solution: that you actually return the FMOD::Event* from your EventStart() function and cache it for state queries.
- Adiss answered 7 years ago
Please login first to submit.