Okay. So, both me and my partner are complete and utterly new to the expression world, because for the most part, we use very few expressions in the first place.
What we're essentially trying to do, is create a videogame health-bar, and it goes down every time an audio que plays.
We know how to make it go DOWN when the audio plays, but then it goes back up to the original value instead of staying down, and then adding more, and more as each audio que plays.
This is our current code, and yes, it's probably horrible. Like I said, we barely know what we're doing. The problem we're having is it isn't holding the current value when it adds the 10 to the linear wipe we're using to tick the health bar down. I feel like this should be simple, but we're not sure. ANY help would be greatly appreciated.
Notes about it:
- "audio" is the keyframes from the audio layer, made easier by Sound Keys
- counter being set to 51, is because the linear wipe doesn't make a visual difference until it goes up to 52, and then it ends at 94 (yes I'm aware
of how dumb that seems).
-audio > 35 is the threshold for when we want the health to tick down, and by 10(%) we want it to go down every time it hits. We were thinking
that with an else of "counter + 0" we thought it would just keep the value, and then anything else is that isn't over that threshold of 35 wouldn't
This of course wasn't the case.
One of the trickiest things to get used to with expressions, is that no data generated by your expression persists from one frame to the next, so there is no "holding" a value--you have to recreate it on every frame where you need it. There are some tools to help you do that, valueAtTime() being one of the most useful. So for your example, your expression might have to loop through the timeline, frame by frame, up to the current frame, using valueAtTime() to find out how frames in the past the audio value was above 35 (or how long ago it went above 35, depending on what you're trying to do) and base your calculation on that.