Prevent multiple mouse clicks when firing weapon

I’m trying to prevent multiple mouse clicks when firing my characters weapon, every time I click to fire a shot is made (or multiple on a timer if held) however, if released and clicked again another shot will be made.

Is there a way to prevent the player from spamming the fire button?

Thanks,

This whole thing is not as easy as it looks.
At some point you want autofire weapon it will mess everything up.
I made autofire actor component, but sadly last thing that is unsolved is that rapid clicking.
So i cannot share blueprint really (it also has some marketplace content)
But i can write what i did:

  • i made 2 mouse events (in player controller) that are “start fire” and “stop fire”. created also dispatchers for them, so mouse event directly calls corresponding dispatcher
  • then i made 2 events in weapon blueprint that i assigned to dispatchers in player controller.
  • when i start firing i remember “game delta seconds”
  • then i fire shoot, and calculate next time weapon can shoot )it is game time seconds plus autofire delay)
  • then i just wait until current game time seconds is more that that calculated time. (on event tick simple branch until time for shoot)
  • when its time i call “Shoot event”

For spamming mouse clicking you need to do one more gate, and do not update next time to shoot when mouse is clicked

“Autofire & Authority” macro:

Whole graph for component: