Running Out of Battery Effect

I have this UI set up to create a CamCorder screen, how would I make the battery image flicker when it turns red? Do I need a FlipBook?

image

Do I need a FlipBook?

Sounds like an overkill. How about a looping timer that toggles widget Visibility on / off.


If you need an example, do explain where/how you charge/drain the battery.

As soon as the UI pops-up, I activate a timer that every tot seconds (it can be changed from the Details panel drains the battery of a certain ammount.

Would another timer be better to do what I’d like to do with the UI?

Sounds like a straightforward idea to me.

1 Like

Use an animation created inside of the widet editor.
Make the progress bar a variable and add it to the animation track.
You can then play it back on loop once the battery is draining.


1 Like

That was my first idea, but can’t find a tutorial to use it in C++ since I am mostly using that instead of BP.

Can I do it in c++ or would you suggest me to just do it in BP?

1 Like

Thank you for the patience! Much appreciated!

You could also use BlueprintImplementableEvent to create a sort of scafolding function to have the definition exist in c++ and later be implemented in your widget (your c++ widget would have to extend UUserWidget)

1 Like

Didn’t think of that! But yeah, you’re right. Its seems far easier than what I originally anticipated. Thank you!

I managed to just do it from C++, alas it seems that it clashes with the function to deactivate/activate the GUI (As in, if I recharge the dinamo and I Implement the animation, it doesn’t turn off the GUI while my Character animation is playing; if the animation is off, the GUI disappears just fine.)

Shoud I deactivate the animation instead of stopping it when I don’t need it?

Not exactly sure why the character animation should impact the gui animation (they are two separate things)

The gui animation animates visibility so yes you need to stop it to not have it override the overall visibility.

You probably need to stop it and set the visibility to hidden.

(post deleted by author)

Found out the problem: I forgot to stop the animation when the character is putting away the camera, and stopped it only when either got fully recharged or out of battery. My bad.

EDIT: NVM, i thought I found the problem, but apparently, if the animation is playing, it won’t stop the timer of the battery drainage for some reason…

battery.zip (62.3 KB)

key 1 => start drain
key 2 => start recharge
key 3 => stop drain

(post deleted by author)

Just found the problem: I don’t know why, it wasn’t handling the MontageNotify (which is handling the ClearTimer stuff).

Changed a line of code and worked like a charm.
Thank you!