queue triggers

Evening everyone.

Im wondering if there is a way to queue up triggered events so that they do not overlap. currently I have a trigger box which plays a sound and displays a graphic when the player crosses its path. works a treat unless you cross another one before its finished as then the second sound is played over the original and the new graphic is displayed. I would like to find a way to queue the events up so that they play after each other rather than over each other. I thought of loading the variables into arrays and cycle through them but Im also aware that you cannot loop through an array and add to it at the same time.

anyone else have any ideas on how to do this?

Regards

When you enter the trigger, instead of playing the sound/graphic right away:

  1. Add an entry in an array (of the type of your trigger, I’m assuming it’s a self contained blueprint that has a trigger in it and plays the sound/graphc itself)
  2. Immediately call a custom event (let’s call it ProcessQueue).

**ProcessQueue **should **Get **the object at index 0 of your array, verify that it’s **valid **(i.e. there’s something there), verify that a custom “SoundIsPlaying” boolean is false, and if that all passes then you:

  1. Trigger the sound/graphics
  2. Immediately set **SoundIsPlaying **to True.
  3. **Remove **Index 0 from the array.
  4. Wait for your sound to be done (use a delay node)
  5. Once the delay is done, set **SoundIsPlaying **to False.
  6. Call ProcessQueue again.

You don’t need to loop through the array at all, just always get index 0 and remove index 0 once you’re done with it (removing an index or item from an array rearranges the array, so what was index 1 will now be index 0), and once you run out of things in the queue, ProcessQueue will see that index 0 is invalid and then you just do nothing.