Download

Help with Flashlight using BP

Hi,

I am new to Unreal and I am trying to make a flash light system,

where its drains when you use it, and you need to pick up batteries to keep it going.

Already go the flash-light working when I press the button.

Any advise on what I should use or make will be very helpful.

Thanks

599f0c8a2b2f267a397b2551c6bb087f6ffbcd01.png

You should create an variable to store the battery level. For example, an float.

An then, while the Flash is on, it will subtract a certain value from that variable.
When the variable reaches the value of 0.0 the Flash will turn off.

By the way, isn’t that Flipflop totally useless? You’re basically saying: If A then “Toggle” and if B then “Toggle”. You could get it of it and have just the one “Toggle”. Surely?

HOWEVER. If you want the battery to drain, you would use “Toggle Visibility”. You’d use a node that sets the visibility (Can’t remember it’s exact name now).

This is so you know what mode you’re in. THAT’S when the Flipflop would be handy.

After that, You’d create a Bool (Yes/No) variable and call it Flashlight On? and another called “Out of Battery”.

You’d also create a float called “Battery” with a default value.


Now set the “Flashlight On?” to true after you turn the visibility to on and set it to false once you turn the light off.

You’d then have a “Tick” event and use the delta time and minus it against the “Battery” IF “Flashlight On?” is set to true. If false, you’d add it to the Battery float. ONLY IF Battery is < 500 (For example).

Then in the Tick, you’d see if Battery = 0. If true, then set “Out of Battery” to true. If not, then set it to false.

THEN if Out of Battery is true, you’d set “Flashlight On?” to off.


This sounds stupidly complicated, so give me a few minutes and I’ll create the BP for you.

Just uploading now. Links will be in this post when done.


EDIT:

Images: ONE, TWO, THREE and FOUR.

Project: HERE.

Hope it helps!