I’m trying to think of the best way to do this without using the EventTick node. I generally find using EventTick for a larger more involved BP is a “bad habit”, something avoided if possible
I mean that solution works. It fires something the moment you hit the button, has a reload pause, allows you to continually fire by holding down and prevents you from firing faster by spamming the fire button
You could set a looping timer on the “fire pressed” event, and clear the timer on the “fire released” event.
The interval of the timer would be your “reset” (or auto-fire) time.
I’m not at the engine right now, but it would simply be:
FIRE PRESSED EVENT -> Set Timer (call function FireProjectile) looping, 0.5 second time -> call function Fire Projectile (so it actually fires right away)
FIRE RELEASED EVENT -> Clear Timer
I find this straightforward and easy to read. Your mileage may vary
Two things, how do you add that “node”, to tidy things up?
Won’t this continue to fire one last round up to half a second after you’ve released your fire button? Shutting off that gate won’t empty the delay node from firing?
EDIT: nope you’re right it won’t fire!
Although won’t spamming the fire button continually open and shut gate and fire pulse through without incurring delay? Your delay will only be active if holding down button
Thanks though, never would have thought about using an event like that.
I’m not even sure if I know how you’d create that event
Does the function fire before or after the timer? If it’s before, then that will introduce a delay before firing, and if it’s after, well, by releasing you’ll clear the timer so by spamming the key you can continually fire then clear the timer without having to wait out the delay… Firing faster than you’ve planned to let the player.
Or am I wrong?
Thanks for your reply though, always good to see the different way people handle situations
Releasing the button closes the gate, so it will no longer fire. It will be closed when the custom event fires.
However, it doesn’t stop you spamming fire, you would have to do something like this:
Jwatte’s solution would be a lot more simple.
That node is a reroute node, type it in when you drag off from a node. The event is just a Custom Event node.
I need to study that a wee bit. The firing model you’re using is a LOT more complex than I need but I think I can steal some of those ideas for other things I am doing
I see. Then another approach would be to flip the order of the gates, and fire the first shot on fire-start, and then keep firing as long as the "is touched’ event is down.
This is that option (although I haven’t actually tested it.) I’m not sure I like it any better (in fact, I like my first proposal best but this does not use event tick, and is still reasonably simple.
(Maybe the delay should be a re-triggerable delay.)