Prevent Animation Button Spam

Hey Guys!

Im working on a small shooter project for myself and have come across an annoying problem.
Im able to get my character to switch weapons by pressing E. Now the issue i have is that if i spam E then the animation is spammed.

My question is how can i limit the key presses so that the character doesnt spam the switch weapon animation?
Example of the spam is below:

v=q4nz5_ueRmo

These are the blueprints that i have that deal with weapon switching:


^^^ this is in the PlayerController blueprint


^^^ This deals with the weapon switching

I thought of using a do once loop but that just only allows one weapon switch.
I just want to prevent switching spam

Any ideas?

You are in dire need of my patreon videos I cover every bit of this stuff, even replicated just too much for forum posts.

For your few last posts it seems you are missing an entire set of logic that is for your “weaponstates”

An example is a state for swapping the weapon and a check on those states before you allow something to happen.

I wish I could just explain it all in a forum post, sadly its to long.

you need a isswappingweapon state to tell it if the weapon is already being swapped, don’t allow it to swap again until the current swap is complete…

Back to the other post where I helped you with reload…

A weapon has states like isreloading isfiring isswapping etc etc…that’s how you prevent it from doing weird **** based on allowing or not allowing certain things to happen based on what state its currently in.

Another example would be like if the weapon state currently isfiring don’t allow it to swap
if the weapon isreloading don’t allow it to switch
if the weapon isswaping don’t allow it to fire
etc etc

You are missing a whole line of logic that is for controlling that kind of stuff…

join me on patreon, you will learn so much it will make your brain swell to Epic proportions!

If it’s just the animation that’s bothering you you can check whether the montage is playing (search for montage playing) check it in a branch and if the montage is playing don’t play the montage again. Easy!

that aint going to stop the logic from running…sure the animation wont play but the weapon will magically pop into your hand anyway

Yes, but that’s not the problem. The problem occurs when pressing the same button several times and by that time the correct weapon is already in your hands.
Edit: Okay I guess not, if there’s only one button for switching weapons. But then it’s a matter of gameplay: should you be able to switch your weapon at all times? If yes: stop the animation. If no: implement some switching logic. You could do this with the animmontage is playing too.

Yeah the player is able to switch weapon whenever they want to