Flashlight power?

Hey guys. I’m making a horror game in UE4, and I’ve got a simple flashlight going. I’m trying to add power to the flashlight, and I think I get how that works, but what I’m really having trouble with is recharging the flashlight. Basically, I want it to recharge the flashlight while it is NOT in use. So as long as it’s off, it will recharge. When it’s on, the power goes down. If that makes any sense. Any help would be greatly appreciated. Thanks!

Subtract from the power variable every however long (clamping at 0) when the flashlight is on, add to the power variable every however long (clamping at 100%, or whatever the max is) when the flashlight is off. Turn the flashlight off once the power reaches 0.

Here are some tutorials from a community Youtuber.

Edit: Fixed Link

That’s actually the exact video I was looking at. I just don’t understand how to add power, not by button press or batteries, but by simply not using the flashlight. So every second or two you’re not using it, your power goes up.

You want to check if the light is On, and on the tick event do a check for it returns false for LightOn or so then the battery will add by 2. You can add a delay to the line on the tick to do this.

Tick->Delay->IS LIGHT ON?->false->Flashlight Add