x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Reset a UMG widget

Hello,

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.

alt text

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

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.

Thanks!

Product Version: UE 4.22
Tags:
menu.jpg (59.8 kB)
more ▼

asked Aug 13 '19 at 06:56 AM in Blueprint Scripting

avatar image

yateam
21 4 8 12

avatar image SebaSopp 6 days ago

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)

avatar image yateam 6 days ago

I animate the value of SizeX (Canvas Slot IIRC). I will try that. Thanks

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

2 answers: sort voted first

First what i thinking - get your animation variable, and play it reverse with start time of full length of animation (or zero, i dunno from where it counts time). https://blueprintue.com/blueprint/m-sip5nz/

more ▼

answered Aug 13 '19 at 08:09 AM

avatar image

SpynderMK
182 3 4 10

avatar image yateam 6 days ago

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

avatar image SpynderMK 6 days ago

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?

avatar image yateam 6 days ago

I don't think this is going to work. When you close a widget it does not play animations.

avatar image SpynderMK 6 days ago

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?

avatar image yateam 6 days ago

I actually thought that there are some more straightforward solutions like for instance: Widget->ResetWidget

avatar image SpynderMK 6 days ago

also, why you wouldn't create new copy of widget, instead of opening old one?

avatar image yateam 6 days ago

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?

avatar image DonBusso 6 days ago

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.

I can make some screenshots if needed.

avatar image yateam 6 days ago

Thanks, will try that!

avatar image SpynderMK 6 days ago

I recreated that logic i described and it worked: Widget logic: https://blueprintue.com/blueprint/_7r347y8/ Widget switcher: https://blueprintue.com/blueprint/e4v8b2_v/ (sorry for the mess)

avatar image yateam 6 days ago

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

alt text

on-continue.jpg (217.9 kB)
avatar image DonBusso 6 days ago

Pretty much the same thing as @SpynderYT just less messy. :P

alt text alt text

createwidget.png (247.0 kB)
widgetbp.png (173.7 kB)
avatar image SpynderMK 6 days ago

1) Call the "Play Animation" node with "Reverse" parameter, and set time to End time of animation.

2) Call the "Play Animation" node BEFORE everything else, so it'll fire before closing.

avatar image yateam 6 days ago

Thanks! Seems like it is working now! These 2 notes are important

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

This, sort of, works. Don't really like it - offset is hardcoded.

alt text

offsets.jpg (340.3 kB)
more ▼

answered Aug 13 '19 at 09:38 AM

avatar image

yateam
21 4 8 12

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question