Play sound based on current state of energy bar?

Not sure if this is doable (I haven’t seen any sound fx tutorials mention it, but I could be searching for the wrong terms). I’m using the equivalent of a ‘mana bar’ in a third person player rpg game for energy weapon types (it will be slightly different based on the player class). The player has to use the weapon by the time the energy bar reaches 100% or it overloads and causes damage to the player.

The bar starts with 1 point and gradually increases by 1 point every half minute up to 100 points (or a specified max), or you can use items to speed it up. The idea is to use the weapon while the energy level is as high as possible, but not going past that point and putting the player at risk. I want a sound to play when the bar passes 60% full, 80%, 90%, 95% and 99% (for example), as a sort of auditory warning system. The sounds are 1-3 seconds long and increase in intensity.

To make it a bit more complicated, there are a different set of sounds depending on the player’s class, as the weapon is different per class. So when the bar updates, I need it to check if it’s gone over one of the intervals (i.e. 60%), then check for which of the 6 classes the player is assigned to, then find and play the 60% sound for that class.

I’ve got the energy bar itself working and updating correctly on a timer. But I’m not sure how / where to incorporate the sounds? I’m guessing it will be like a low health warning that some games have, except run backwards (as the trigger is going over a set %). But so far I haven’t found any tutorials showing anything like the above that I can repurpose.

Industrial is completely fine with me. However, I set up the above on my third person character, added in the sound asset, hit play and took my energy bar down to 58%. It should play the first sound file when it bumps back up to 60%, but nothing happens. I renamed it ‘EnergybarSound’, but otherwise it’s exactly as the above image.

I can’t see anything wrong with your logic, so I’m wondering if there’s an audio setting or something very obvious that I’m missing? I already have cued sounds working fine, so I’m not sure what I’m doing differently.

Ah - it was a guide, I’m suspecting you have a problem with the float not being exactly on the button.

Try nearly equal

336661-screenshot-3.jpg

That doesn’t seem to work either. I also tried an error tolerance of up to 5 and playing with the timer, but still nothing. Do I need to create a cue with the audio file or do anything else with it (just spitballing here)?

I managed to get it to work finally! I had the trigger for the sound event attached to the energy points deletion event rather than the regeneration one. Works great now! Thank you for your help. : )

You could use a ‘skip chain’. Bit industrial, but does the trick: