I’ve run into a problem with playing a looped FMOD event.
Basically I want to trigger a looping event once the player has collected a certain number of items.
My pickup manager and “Can proceed” bool live in my Player Movement script, which is passed into this LevelExitSound script.
The ExitIsOpen function checks whether canProceed is true and then triggers the event, but as this function is called in the Update function, it overloads.
Adding the Playback State bool has stopped the sound retriggering but now it doesn’t trigger at all. Any suggestions?
The event’s playback state needs to be polled with
Something like this should work.
pM = player.GetComponent<PlayerMovement>();
ExitOpen = FMODUnity.RuntimeManager.CreateInstance("event:/Environment/Exit"); // Create event but don't start it so we can poll it's playback state
ExitOpen.getPlaybackState(pbState); // Poll playback state
if(mP.canProceed && pbState != FMOD.Studio.PLAYBACK_STATE.PLAYING)
Thanks Jeff! Worked a treat.