How do I set an imported animation to play on key press?

Okay, I imported an animation and skeleton into UE4, but I was unable to get it to perform the animation when pressing a certain key. I set up G as key input and created a variable ShouldPlay in the character BP.

In the animation BP I created the update animation, try pawn, cast to mycharacter, and so on…but when I hit PLAY and press G it doesn’t play the animation.

Take a look at this tutorials: ? It will answer all your questions :slight_smile:

Or do it like that:

  1. in the “my character bp” you have to add a bool variable which will be activated/deactivated by a input
  2. in the animbp you have to cast to your character - then create another variable in the anim bp - get the variable from the “my character bp” and connect it with the set node from the bool variable in the animbp
  3. go into the anim graph and set it up like on the picture -> so in the state you have to add the animation - the link to the state should just have the variable - the link to the idle state needs a variable + not

Okay I knew how to do all that except the animation graph and state machine thing. I however don’t have an animation montage. I only have ONE animation I’m trying to test and see if it works.

What do I do in the animation graph? I dragged and dropped the green file sequence and connected it to the final animation pose.

When you just have one anim you could do it the way that I posted :slight_smile:

I will post a link to a video in a sec

Here we go: ?v=pLUHwVTRhCs&feature=youtu.be -> I think it should also be possible with a “play montage” in the character bp, but I prefere this way (because I use different animation modes -> friendly, one hand weapon, …) :slight_smile:

Thank you it helps, but I still can’t get it to work.

Do I need to have an idle animation in the idle state? I connected an Idle state and TestAnimation state to each other, but I currently have no idle animation connected to final pose in the Idle state. If that’s confusing here is what it looks like for me:

No, you dont need an idle animation in the state -> which template do you use?

I use the FPS blueprint template.

I made my own animation using the FPS shooter model hands/arms from UE4. I imported the fbx from blender.

Ok, then replace the “cast to character” with a “cast to my character” and delete the arm slot in front of the new state machine :slight_smile:

I already had it set up that way. This is how my event graph looks like:

I’m using the 4.3.0 version of UE4 if that matters.

Hmm really strange -> take a look at this video and check if you do everything like that: ?v=OvBs4lY3tIc&feature=youtu.be

btw, have you already recompiled the anim and char bp?

Can I send you my project folder? If you open it up and have the same issue at least I’ll know it’s not on my end.

Yep, just send it to me as a pm :slight_smile:

Alright sent.

Ok, I will take a look at it :slight_smile:

:wink: You forgot to add your animbp to your character mesh in your char bp

Yep that did the trick…boy I’m an idiot.

Hey, thanks for the help man, much gratitude.

Hey , This really helped me out, thanks a lot! I have 2 questions… I am setting up a DOTA style attack, where say Q,W,E, are the attack keys. I set up the first one like your example. Great stuff, worked perfect.

  1. Is there a way to let with key press, to let the animation finish. The way this is set up, when you release, the animation stops immediately.
  2. Setting this up through the sequence node, does it matter what slot this goes into or is there a different node that would work better.

Great stuff here, thanks in advance!!

I know this thread is old , but I have same question of poster above. How do you set it so just pressing the button plays the whole animation once? The way it is with press to activate animation and release to stop it, you have to hold the button to go through the animation, the second you let go of the button , the animation stops.Otherwise if you remove the release pin connection , he keeps looping through the animation and don’t stop.

Ok , so I was able to accomplish this by putting a delay of 1 second between the press and release variable sets.