Playing Animation in level due to widget condition

Hi, so I created this real time character settings widget, everything I’ve set up seems to working fine except the animation, how can I make the referenced character in the level play an animation when I enter the character settings widget from the options widget?
Thanks in advance

hi @ValLevi

Not sure if this will work, but get the player pawn, or the pawn you are referencing and use Play Animation on the skeletal mesh. lets you choose the animation.

If this node does not exist then a simple Cast to Character should fix this

I’m playing an animation montage so that it can be looped
Is there a way to loop animations?

it has a loop enabled tick in the Play Animation node

Aiit thanks, lemme try em

It’s working, now I want it to play when a certain condition is true and I put the condition in a widget blueprint which sets the condition to true on tick and false when I hit the back button
Ps. The character reference is on the level blueprint, so I got a reference of the widget to get the condition and then I used a branch of the tick of the level blueprint, this doesn’t seem to work tho and it flags errors after I leave the editor

where are you placing the animation code? on the player or the widget?

I would call it from the widget, and do the check on the widget side also

The animation code is in the level blueprint, I dragged the player character into the level and I’m using that as the reference cause that’s the character I want to play the animation, is this wrong?

its not wrong in any sense. But if you need to use the widget to control this action i would do it inside the widget.

you can easily still get access to the character inside the widget so detect when you change the value and play the animation or stop it accordingly without leaving the widget

I actually tried this method at first, so as to narrow where the codes are but I couldn’t get a reference of the character I dropped in the level

ok so best way is if there is more than one character, and its not the player, then add an actor tag with a name you remmeber “AnimCharacter” or something

then Get AllActorsOfClassWithTag and just take the first one it finds (just dont tag any other characters or they all be dancing!)

1 Like

:rofl::rofl:
I guess I’ll have to use this, I thought about it as a last resort, I just wanted to ask if there was any other way first, thanks alot​:slightly_smiling_face::handshake:t3:

if its hard coded to always use that character. then in your widget add a variable of type you character blueprint object reference.

In your level blueprint after you have spawned the widget. Set the variable with the character. then inside the widget you just access the variable object reference you made

I understand the level blueprint part but I don’t get the widget part, you said I should create a variable within the widget blueprint and make it an object reference of my character, then in the level blueprint, I should make a reference of my widget blueprint, then off of it, I should set that object reference in the widget blueprint on the level blueprint, then set it to the character I dragged into the level, this is what I understood, am I right?

in the level once you have created and put the widget onto the viewport. Set the variable (the one in the widget) with the character you want to play the animations on. (you may want to create a variable in your level BP to store the widget you create. making it easier to access its variables etc)

then inside the widget code you only have to access the object reference to perform your code al inside the widget itself.

Aiit i understand now, though the widget isn’t added on begin play, it’s gotten from the options widget, the only widget that’s put on the viewport is the mainmenu widget

1 Like

I’ve tried this last method you talked about, it doesn’t work out because of the same reference issues, I went ahead to create another character for it since there wasn’t any other alternatives, thanks​:slightly_smiling_face::raised_hands:t3: