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"

UMG widget button, click expand, click again collapse?

Hi, I'm making a simple interface, I added a button that onClick plays an animation, and I want it to play the animation in reverse the next click, and loop between these two behaviours forever? how do I do so?

Product Version: UE 4.20
Tags:
more ▼

asked Aug 03 '18 at 04:23 PM in Blueprint Scripting

avatar image

fael097
13 1 4

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

1 answer: sort voted first

Hi there,

One simple way is you can add a boolean variable to your widget blueprint to keep track of the state of the button click and then depending on that value either play the animation forward or reverse. Here's an image showing a quick example of how you'd set it up in your widget blueprint.

It's important that 'Button Clicked' is set to false by default so your animation will play forward the first time with this setup.

alt text

I hope that helps!

capture.png (228.4 kB)
more ▼

answered Aug 03 '18 at 05:35 PM

avatar image

TitanicGames
176 1 3 3

avatar image TitanicGames Aug 03 '18 at 05:52 PM

In addition to that, you can add a check to see if the animation is currently playing so you can reverse it's playback mid-play. This will help with making the animation play smoothly even if the user is rapidly pressing the button (without that step it will jump to the end position of its current playback before reversing, which imo doesn't look as polished).

Try this out and see how you like it once you get the prior bit of code working. Again, I hope this helps you achieve what you're trying to do.

alt text

capture2.png (275.6 kB)
avatar image fael097 Aug 03 '18 at 06:01 PM

wow, that was really helpful. from that I managed to expand it to create branch menus from that button, gonna have some fun making this interface. thanks a lot!

(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