Mouse left button down to shoot automatically

Hey

How can I shoot automatically when I hold the mouse left button down and stop again when I released it. There is only Pressed and Released in the mouse event.

in blueprint… Thx

Make a loop with delay which time will be time between shoot and Boolean which say “IsFireing” and create gate note which will block the loop when “IsFireing” is false. Now on key press start the loop and set “IsFireing” to true, and on release set “IsFireing” to false.

I can’t get it to work… :frowning:
Can you see what is wrong.

Ah do you can open and close with action, sorry i didn’t know about it. remove the boolean (it’s actully not needed), make a “Branch”, to input of it plug “Pressed”, first output of it plug to “Open” and Secound on “Enter”. Now Delay, plug “Exit” of gate to input of “Delay” and “Completed”, make another Branch, first plug to you fire mechanics and 2nd output plug to “Enter” of gate. “Released” plug to “Close” ofcorse

There one flaw in this thru, Tick is called in every frame, so fire rate be depended of frames per second… in other words people with better GPU will have gameplay advantage :p.

Deata Secounds is outputing time between frames specially for youto scale varable changes and make code time dependent. Thats why i proposed delay format, internationally SetTimer could be used which which can be set to intervalmode

I’d set a variable on the Blueprint that holds the fire position with Pressed and Release, then using the Tick Event (called for updating in the scene), test that variable with a Branch, then hook that up to your fire logic.

Yes it’s correct. CMD: STAT FPS show that… :slight_smile: but it works. Maybe I will fix it someday…

Ok here you go, this is my solution :slight_smile: Insted of Fire Impulse use your fire block

I updated my anwser with image :slight_smile:

Yeah, that is a consideration, depending on implementation of how the weapon fires (fire rate could be set in the Fire function, etc.).

thanks to both of you… :slight_smile:

Thank you so much!i!i!i!i!

I recommend you accept this answer to resolve it. (Check mark under vote)

Since this question has already be answered, this site has also become extremely useful to me! Hope it helps! (:
[1]: http://www.breadfish.co.uk/

That helped so much. I tweaked it a little bit to use the values of a curve as delay time. I added two vars for it, the curve itself and a time count float.

I use this variation for an add item menu button, to add items with a button pressed variating the ratio.

I don’t think this is a good implementation, since with this approach you can just quickly click fire button and fire faster than your delay.

If the auto-fire function is just a convenience, the above solution should work. If you want to have a hard limit on fire rate, you can uses this, which I based on the above solution.

Thank you, it works perfectly.

I couldn’t get the above to work as intended but i found a solution using parts of other answers