So, you’ve got a series of audio files designed to loop. You want to create an event that, when triggered, plays one of these audio files on loop for fifteen seconds - and you want players to be able to reset the timer at any time without changing which audio file is playing.
That’s no problem. There’s a number of different ways in which you could do this, but this one is the easiest:
- Create an event.
- Add a new parameter to the event. Name this parameter “Fires” and give it any range you like. (The default of 0-1 will work just fine.)
- Set the parameter’s initial value to exactly half of its range. (If you went with the default range of 0-1, you should set the initial value to 0.5.)
- Add a random modulator to the parameter value, and set it to 100%.
- On the Fires parameter, create one single instrument for each of your fire audio files, and lay them out evenly along the parameter. (Or unevenly, if you prefer. The important thing is that there should be no gaps between them, and no areas of overlap.)
You’ll never need to set the Fires parameter in your game code. Instead, whenever an instance of the event starts playing, its Fires parameter will be given a random value. This randomly selects a new audio audio asset to play when an instance of the event starts playing, but not subsequently.
- Create a new preset parameter. Name it “Timer” and give it a range of 0-16.
- Give the Timer parameter a velocity of 1/s.
- Assign each of the instruments in your event a parameter condition for the Timer parameter, and set the range to 0-15.
- Enable cut mode for each of the instruments.
The Timer parameter acts as a fifteen-second timer that starts the moment the event does. Once it hits 15, whichever instrument is currently playing will stop playing. All you need to do to reset the timer is set the timer parameter back to 0.
Let us know if this method doesn’t suit the requirements of your project; as I said above, there are a umber of other ways in which you could achieve the same thing.