How to implement WORKING fully automatic gun logic ?

Hi everyone,

I’m currently looking for a cleaner way of handling my automatic weapons, including slow rate of fire. What I currently have is fully functional but relies on Tick Event which from what I understand isn’t great, since introducing Delay will block anything else I’d need to do there later on.

Here is my FireWeapon function (you can ignore the BIsShooting input, that’s just me testing stuff) :

And my Tick event :

Now, here is my issue. I have looked at dozen of tutorials and NONE of them work nearly as well as my silly Tick :

  • Either they don’t factor in tap-firing, which in my case REALLY is an issue since the gun is a cannon that has a 2 second reload speed.
  • Or, you can somehow get stuck with a “CanShoot” boolean to false when clearing a SetTimerByEvent (which would happen less often as RoF got higher, hence why those tutorials were ““working”” for rifles).
  • Or, there is a delay at the beginning equal to the rate of fire, which is never ok in an FPS, but even less with a 2 second delay…

So here I am, after trying many things, wondering how the hell I’m supposed to do a clean, proper automatic cannon with a slow rate of fire, that cannot spam tap fire, and basically behave like you’d expect, based on click events and not Tick.

Thanks a lot for your help :slight_smile:

SetTimer is definitely the way you want to go, you just have to handle cleanup properly. Delay on Tick is a broken solution.

i’ll send a pic if i get in editor soon

Hey @Auran131 thanks for your input. I do believe something like you say is the solution but I cannot figure out how to make it work properly. I’m looking forward to test your solution !

So i dont know exactly how you want to handle it but this should be the jist of it

1 Like

Well, good sir, I have extensively tested your solution and it seems pretty bulletproof (pun intended). Thanks a lot, it’s exactly what I needed.

1 Like

This changes up a bit once you go down the multiplayer path.

Current model would send an RPC to the server each time your fire a shot. This is not network performant by any means. You’d want to send an RPC for trigger pull and one for release.

Just a heads up.

1 Like