how to use UMG buttons to drive different state in animation blueprint

Hi there,

I’m new to unreal, and I am stuck with some problem about button in UMG to control each state in state machine. I have watched some tutorial and tried following them, and still didn’t get it.
In my set up, Animation BP, I created variable"Idle to Float" to switch between Idle state to float state. Then in UMG, I create variable “Is Float?” and hook it up with button press, with flip flop in between. My goal was when clicking button it will switch “Is Floating?” to on and off then it will drive “Idle to Float”. I’m not sure I understand it correctly. Please help. Thank you in advance.

Here are my screen shots
screen1
screen2

It sounds like you are trying to fly. First of all, you can set that in the character movement component. :slight_smile:

  1. Select your character movement component in your Character Blueprint, and then type “fly” into the search area of the details panel.

  2. Check the box to allow your character to fly.

  3. In the event graph, go ahead and bind a key to set flying to true. You should be able to pull a flying node out of a character movement getter. (We will change this to your UMG in a moment).

  4. Check that it works. Your character should now be able to “fly,” but the animation won’t be there.

Next the Anim Blueprint…

  1. In the animation blueprint, pull off from the “get pawn owner” node (if you are using an animation blueprint that comes with starter character, it should be the one that has a bunch of things pulled off of it already). Get the character movement component from it.

  2. Then, from the character movement you just got pull off the “is flying” bool.

  3. Make another flying bool inside the animation blueprint itself. Set it using the “is flying” bool you just pulled off of character movement.

  4. Go to your state machine and make the rule to swap between flying and not flying be the “Flying” bool you just created for animation. (Obv, regular for entering flying and use the NOT add-on for exiting flying.)

Now go test again. Your character should be able to enter flying state when you use the key you set in your character blueprint to swap to flying. And the animation should work.

Next, you said you wanted to tie it into UMG…
This kind of depends on where you are creating your widget.

  1. If you are creating your widget inside the character blueprint, then all you need to do is make a character variable inside the widget. Then, when your character creates the widget in the character blueprint, pull off from the output and set that variable for the widget to “self.” If you are creating your widget anywhere else, you may have to cast to the character on widget construct to set the variable if that spot doesn’t have a reference to your character handy.

  2. Set your “on clicked” for your button inside your widget to get the character variable and from that get character movement. Then from character movement get flying. Set flying to true.

  3. Don’t forget to add the widget to the viewport somewhere! :slight_smile:

You should now be able to set flying from your UMG widget!

the way I would do this would be to set the is float boolean in another actor in the level. Then get that variable in the character blueprint, maybe a timer? to see when that variable is set.

instead of set in the animation bp try get

Hi, Thank you for your reply. so I should create prawn class blueprint and move “Is Float?” into that? I have tried and I think I got some progress, I change variable to “startfrom Idle”. I put U key in the new charector blueprint because I don’t know how to link new charector BP to UMG yet. and I don’t thing I know what is a timer, sorry. you mean delay node?

What I did, I cast to charector BP and bring “startfrom Idle” variable in animation blueprint and hope that will set “Idle to Float” variable, which I don’t think it did.

I also did put print node for checking, on screen shown that it the text from print node. but I didn’t even press U at all, it still print out. Could you tell me what I did wrong there please? Thanks

I did screen capture here
charectorPawnClassScreen,
Animation BP,
screen,

Hi, @detach789 .I think I saw your post, it shown and it gone. Thank you so much, I’ll follow the direction. sorry I didn’t explain it clearly, actually I’m doing the product visualization, which I don’t know it is the same as character in game. I have like the idle state where it is on the ground, and float state where I animated in Maya it flip multiple time and set static in the air. I set those 2 states in state machine, with “Is Float?” variable to control those 2 states. and I created my UMG in level blueprint. what you suggested was I should do Event begin play>create widget in charactor blueprint?

This is what I have set up in my animation blueprint, I don’t think I do it right, but don’t know how to fix it. please advice. animBP_v003
I’ll try wrap my head around the concept that you suggest and try it out Thank so much

I have tried to sit on it and move node around, but not sure I understand, what you mean by get animation BP? is it still do in animation bp or I should do it in charector blueprint and go get animation bp. so sorry kinda confuse here.

Yeah, I’m still getting used to the forums. Apparently, if I even edit a single sentence in a large post it disappears and goes back to review for mods. I’ll try to keep this post shorter. :slight_smile:

Okay, so you say you still have an animated character that is shown to be flying or idle, right? Because if you don’t have a character with a skeletal mesh, there is no need for an animation blueprint.
So, assuming you have that character, then, yes, everything should still work the same regardless of if the character is flying through a game or flying through a visualization. :slight_smile:

Also, in the currently invisible post, I mentioned dragging off the character movement component in order to access flying in character, but it occurs to me that there may just be a blue node for that (like jumping), so you wouldn’t have to drag off. I know for a fact flying is one of the options that just comes with having a char move component though.