How to keep calling function as long ad key pressed?

Hi there,

I have been trying my luck at making a bow and arrow in c++ and have a simple question. As you know, the bow should fire the arrow with a speed relevant to how long the button has been pressed. A tiny press should not send the arrow flying but a long press should send it soaring. In c++, I know that it is set up so that when you press a button it triggers the IE_Pressed which then calls a function. I have this set up. When the fire button is pressed the projectile shoots once. My question is, how exactly can I make it so that the OnFire() function keeps getting called as long as the left mouse button is held down?

Think of a press and unpress events as on and off switches. Now you have 2 options either use tick or a looped timer. With Tick use Boolean that will do calculation of bool is true, with timer you start timer on press and stop timer at unpress.

On both cases use unpress event as a trigger for final calculations. So i assume you want to do bow charge, then on unpress asside of disbaleing chargeing, you check how much it charge and oyu actully fire the arrow according to state that charge was ended

If you don’t know about timers here you got, you can also use them in blueprint:

If oyu use tick, remember to apply delta time to your calculations, or else whatever you doing will be bound to fps