I have a umg widget with the main menu for my game. When you open it, you’ll see options: Continue, Exit (yes, that simple). When you hover over an item - it slightly increases its width, and when you hover out - decreases. All it’s done by means of animations.
Now, when you click on Continue - the widget disappears and you continue to play the game. BUT, when you summon the menu back - it will show up with Continue button with increased width. This is due to the fact, that reverse animation hasn’t played back and the button in its hover state.
You can see the behavior on the gif here:
[Gif with the menu in action][2]
Now the question: how do I reset the widget, so when I open it again, the buttons would be in their initial states?
For now, I think I can create a widget each time, a user pressed Esc - but that is definitely not a solution.
how about doing this when player closes widget? As far as i can tell you storing your widget somewhere, not destroying it - this why it happens, then you can make this animation play when player doesn’t see it. Also, this blueprint above should immediatly set it to start, equals to “Set animation time to 0”, have you tried exactly it?
Thanks!
Yes, I tried similar to that.
The issue here is that the reverse animation is still visible when you open the widget. You see how the button is getting back to its initial state. And I would prefer that the button should be in the initial state right away w/o any animations
What kind of animation are you doing? If you animate the render transform scale, maybe you can set this value to the default value with clicking on continue (or at reopening the menue)
That’s what I do in my workaround - but I am afraid that it affects the performance, because who knows how many times a user will bring up the main menu. All these widgets are going to stay in memory, no?
what about playing it before closing widget? I don’t know your code, but something like:
Esc → Play animation above → remove from parent, is that gonna work?
Hello,
I think it’s better to keep them hidden rather then destroy and creating them all the time. That way you can still run things in the background if you need to.
I just tried to do this and I had a problem when my button would be stretched when creating a widget but I got it fixed quick time, just had to double check the offset values on my animation. Anyways you should keep your widget hidden and just play the animation backwards behind the screen if nothing else works.
Select your animation and then button and double check offset values at the start and end of the animation.
Just tried that. It does not work, unfortunately the animation does not play when the widget is not displayed. It sort of postponed. When I bring up the widget back - it finishes the animation
This is the code for the widget continue button click event
I know I’m years late to this, but my solution was to play in reverse with an enormous value for the playback speed so that it effectively only took one frame to jump back.