I am implementing a “buff bar” system where I wish to display current status effects for the player with an overlaying decrementing counter. I’m trying to work out the pseudocode right now.
In my character’s blueprint, I can call a custom “Add Buff” event, passing in the duration, description and an icon. From there, I’m not sure. I could make a struct that contains the duration, description and icon and the “Add Buff” event could simply add a new entry with those values to an array.
Then, I could use a timer that calls a function every second. This function could loop through the array, decrement each duration by 1 and remove it if it’s 0.
The problem with this is the durations will essentially be decreased by up to 1 second for each buff. If the timer is in the middle of it’s wait cycle when a buff is added, it will decrement the duration on the new buff before a second has fully passed.
So I feel like I need a new timer for each buff. You can’t create a timer variable so the only thing I can think of is creating a new actor to represent the buff. Each actor would have its own timer and function independently. The character would just keep track of the actors. However, I feel like this may be over complicating things. Is there a simpler solution to this?