Optimal way to handle variable number of timers

You’d be better off utilizing the Tick of the component and the DeltaTime passed in rather than two separate timers. This way you’re using an existing system of the engine that’s already ticking every frame. Everything else sounds good!

So I want different effects running at variable times to be affecting the character. I want the effects to be maintained in a database to allow for flexibility in tuning.

I am considering using a TArray of custom “Effect” classes (parented to Actor Component) to represent the various timers in play for a character. When I want a health over time buff on a character, I create the “Effect” class passing it a reference to the character. The “Effect” class will know to call the “Add health” method on the character. Maybe even pass in the method on the character the “Effect” object will need to call.

The “Effect” class will internally create two timers, one for the overall time of the effect and the other to fire off the incremental (if any). When the overall timer fires, it will call a method on the character so the character can remove it from it’s array. When the object is destroyed, it will handle the cleanup of the timers.

Anyone see problems with trying to do this?

Agreed! I was too focused on using timers! Thanks for the response.