Recently I’ve been trying to get one of my weapons to automatic fire when I hold down the shoot button. However I can’t seem to get it right and it always ends up changing nothing, closest I got to automatic was a 2 shot burst which still isn’t close to what I want. Also for a bit more context I have several weapons that are organized using the integer variable “weapon index” and I’m trying to make automatic fire available only when my weapon index value is 0.
Hey @ShadowFlameSpare!
So the problem here is that you’re using “Started” which should only fire one time on the next frame.
What I would do is use a timer here, with the time being the time between rounds. Put it after the second branch but before SpawnActor. Then have an event, let’s call it Event_AutoFire.
With the time set to, let’s say 0.1.
Now, off of “Canceled” and “completed”, use “Invalidate timer by handle”.
Right click the output pin on the timer and promote to variable. This is your Handle! Now get that and plug it into the Invalidate node.
Hope that helps! If you get stuck let us know!
Hello @Mind-Brain .
I’m pretty new at using ue5 so I can’t perfectly visualize what to do based off your instructions. I’ve been trying different combinations but it always ends up making it unable to shoot. This is currently what I have so far and I’m hoping you could point out what mistakes I made when trying to replicate your instructions into my blueprint. Thank you for helping me out so far.
Okay! Not a problem.
First thing here is the timer. What a timer does is it causes a certain event to fire after a certain amount of time. It’s separate from the execution line of your CURRENT event, which is your input action event.
The other thing here is the input action execution lines. I think you’re unaware that you can merge execution lines from two sources, you just can’t split them into two exits. Also I take back using “Ongoing”, you don’t need that because of the Timer.
Here’s how I do it.
Note, all of this is in the weapon class itself.
The Auto Autonomous Firing
function determines if the client can fire (Macro), calculates projectile aim velocity, requests projectile from obj pool (effectively firing), calls timer, RPC’s server etc.
Short snippet to see flow.
A few of the custom function nodes inside the firing function.