Force keypress by boolean Blueprint

Dear UE4 community,

Is it possible to have a certain button pressed when a certain boolean is set to true.

For instance:
I have a progress-bar for my flashlight-battery.
When F is pressed the flashlight turns on. when my flashlight runs out of power, the intensity is set to 0 and when a battery is picked up the intensity is set to high, and at last when the player presses F again, the battery stops draining and the flashlight is off.
Everything is working out just fine as it is right now but I want the game to force press F again to turn off the flashlight after the battery is dead.

so when the player puts in a new battery, the player has to press F again to activate flashlight instead of the flashlight turning itself back on.

would greatly appreciate any help and sorry for my mediocre english. :slight_smile:

Your best bet here would be to create a function in your blueprint that does all the logic currently assigned to the F button press. Then, when you get that F button press event, call that function. Also, call that function when the battery runs out.

what do you mean by creating and calling a function?

Here’s a tutorial on blueprint functions:

Worked like a charm! made a function for ‘flipflop A flashlight on’, and made a function for ‘flipflop B flashlight off’. Thank you very much :smiley:

Can you post your solution? I am having the same situation and I cannot find another way around it, the function solution in just words, is not helping my situation.