I'm having trouble preventing sound clips I play from overlapping. I basically have a multi-player action game. If you do something worthy of an announcement, the game plays a sound clip. My problem is if you trigger another sound clip before the first one finishes, it just overlaps the first sound clip.
How can I make it so that the second sound clip will wait until the first one finishes?
I tried adding all of the sound clips to a queue using the "Add action to queue" under trigger-actions, but that doesn't work. I'm not sure why. It must be creating a separate queue for each trigger that triggers it.
Can't test anything right now as I'm heading off to bed, but I guess you could just create your own queue through an array?
Every time you're supposed to run a sound file, set SoundFileArray = that sound file, in the slot of a queue variable - QueueVariable. That is; SoundFileArray[QueueVariable]. Then modify QueueVariable + 1. Once it hits, say, 5 - set it to 0 again. So as a new sound file is "queued", it's just assigned the next slot in the array. Then have a periodic trigger that has it's own queue variable - PlayQueueVariable - and the trigger would just play SoundFileArray[PlayQueueVariable], modify PlayQueueVariable + 1 and if a sound file was played, turn off the trigger, wait 3 seconds, turn it back on. This queue variable would also be set to 0 once it hits, say, 5.
That way you'd loop through the array and play one sound at a time. The waiting time would stop the sounds from overlapping. I hope I made sense, I'm a bit tired.
Rollback Post to RevisionRollBack
To post a comment, please login or register a new account.
I'm having trouble preventing sound clips I play from overlapping. I basically have a multi-player action game. If you do something worthy of an announcement, the game plays a sound clip. My problem is if you trigger another sound clip before the first one finishes, it just overlaps the first sound clip.
How can I make it so that the second sound clip will wait until the first one finishes?
I tried adding all of the sound clips to a queue using the "Add action to queue" under trigger-actions, but that doesn't work. I'm not sure why. It must be creating a separate queue for each trigger that triggers it.
Anyone have any input?
bump
Can't test anything right now as I'm heading off to bed, but I guess you could just create your own queue through an array?
Every time you're supposed to run a sound file, set SoundFileArray = that sound file, in the slot of a queue variable - QueueVariable. That is; SoundFileArray[QueueVariable]. Then modify QueueVariable + 1. Once it hits, say, 5 - set it to 0 again. So as a new sound file is "queued", it's just assigned the next slot in the array. Then have a periodic trigger that has it's own queue variable - PlayQueueVariable - and the trigger would just play SoundFileArray[PlayQueueVariable], modify PlayQueueVariable + 1 and if a sound file was played, turn off the trigger, wait 3 seconds, turn it back on. This queue variable would also be set to 0 once it hits, say, 5.
That way you'd loop through the array and play one sound at a time. The waiting time would stop the sounds from overlapping. I hope I made sense, I'm a bit tired.