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.
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.
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.
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.
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.