How can I prevent a button from being spammed?

Hey I hope everyone is doing well.

I have a UMG menu that plays an animation of the menu being lifted off the screen like a piece of paper when you exit the menu. My game is for android, and recently I added functionality for the android back button, when I realized my method to deal with the button being spammed or hit repeatedly while the animation played wasn’t working. Below is my attempt.

And that bool ‘hasBackBeenHit’ is set to false on event construct. Is there a standard way I should deal with this that I’m unaware of? It’s like the user is able to cause my animation to start over by spamming the button.

Thank you so much to anyone willing to take the time to help.

1 Like

No, there no standard way to do it. If your menu widget is just hidden not destroyed, only thing you could do better is to have general menu state bool and set to false when dissaper animation is start playing and set to true when appearance animation finished and use that bool as a filter to any menu related events if needed, including back button.

1 Like

Let me know if this solves the issue.

3 Likes

Maybe you can use DoOnce macro. You can trigger Reset pin of DoOnce after your animation finished. I couldn’t imagine your workflow in my mind but you can use DoOnce on anything to block spamming.

2 Likes

That’s exactly what the hasBackBeenHit bool is for.It doesn’t seem to work. And just to clarify, I use “remove from parent” after the animation completes. I mean, it kinda works. But it’s still spammable a little.

But let me say thank you for your input. I appreciate your interest in my question.

Thank you SO MUCH! This worked perfectly, easily, the first time I tried to implement it. I really appreciate you.

I will accept this as an answer if you want to do change your comment to an answer.

Sure why not :slight_smile:

Thanks for your answer. I really appreciate the detail. This is a great example of what I wanted, but Saglam gave me a very similar answer first. I’m not sure what the protocol is, to whom to give the ‘best answer’, but I gave it to him before your comment. I’m just writing you to let you know that I appreciate your work.

I didn’t notice his response and just wanted to give you an image. Thanks for the response!

this solved an issue i was having with my game, thank you!

Thaaank You so much it works like charm