AnimGraph, Can enter transition with Action/Axis Input?

I am currently learning how to set up animations and I’m trying to add a Sprinting animation, first I did just add the sprinting animation to the blend space you get with the 3rd person template and that did work just fine but rather than just blending the animations I’m currently trying to add something like a dash animation before the character goes in to the sprinting state. I have barely touched coding in my entire life so I’m very new to it so excuse my incompetence^^ I thought that the easiest way to do this would be to have the “Can enter transition” just check if I’m actually activating the action input that is sprint but alas after some tinkering I still can’t seem to figure out how to do that, so inputs or not, what would be a efficient way of doing this?

Hi Creamshake,
You are definitely on the right track with how to set up your dash animation. Thankfully, for both of us, coding won’t be necessary. Haha.

First, you’ll want to check if you are performing the desired input in your Character Blueprint (not the Animation BP). I made a quick example where pressing the Shift key would set a variable that I created called ShouldSprint to True (and releasing shift would set it to False). Like so:

Next, you’ll want to access that variable (ShouldSprint in my example) in your Animation Blueprint so that you can use it to trigger your transition. You can do that by “casting” the pawn owner in the AnimBP EventGraph to the Character Blueprint that you were working in earlier. Once you’ve done that, you can access the variable created above in the Character BP from inside the Animation BP, and use that to trigger your transition. What my AnimBP Event Graph looks like:

Couple final things to note. By default, the pop-up window that lists possible nodes/actions in Blueprints is context-sensitive. So, in order to see the “casting” nodes, you’ll need to drag off of the “Try Get Pawn Owner” node like above. When you drag off of the “Get Pawn Owner” and type “cast” into that pop-up, you should see your Character Blueprint in the list of available nodes. Also, you can see above that I made a new variable in my Animation BP called IsSprinting that I’m actually using to fire my transition. It’s being set to the same value as ShouldSprint from the Character BP.

Whew. That was a mouthful, but it takes way longer to explain it than to do it.

Good luck and let me know if any of that isn’t clear!

I. FEEL. SO. POWERFUL! Works like a charm, thank you for your time!

hi! I was able to follow the setup until the last part. I have not been able to access those variable from My character blueprint in the HeroTPP_AnimBlueprint. What am I doing wrong?

hi! I was able to follow the setup until the last part. I have not been able to access those variable from My character blueprint in the HeroTPP_AnimBlueprint. What am I doing wrong?

Nevermind, I got it. Thanks

i dont find in pop-up the “Cast To MyCharacter”
the name my BluePrint is “MyCharacterTest” and i cant find
can you help please?

Hmm. Were you dragging off of the ‘Get Pawn Owner’ node in your AnimBP EventGraph? As mentioned above, that pop-up window is contex-sensitive; so, it will only show the “Cast To” nodes if you are dragging off of a valid target.

If that isn’t it, try opening your character BP, compiling it, and then go back to your AnimBP and try dragging off of the “Get Pawn Owner” again. At times, I’ve had the available character BP’s not show up in that window if I haven’t opened them during the current editor session.

Those are the two most obvious solutions to me, but if that isn’t it, we can dive a bit deeper. :slight_smile:

Out of curiosity, when I use this method my animations don’t show up to other players in a network game. Does that happen for anyone else?

I am able to set the ‘cast to My character’ in de ABP but how do I set the < Target: Should Sprint> ? I still cant find the variable anywhere.

Solved it… The variable in the BP needs to be set to public

Hi, I’ve done the same as you by casting to FirstPersonCharacter and setting variables, but my animation blueprint references an NPC, and so when I am pressing the assigned keys the cast is successful but the NPC’s animation does not change. Any clues?

I’m 90% sure it’s because your NPC doesn’t have any input events firing. To get around this just create new events for AI and plug them into the same chain as your character is using.

Either in your AI controller or behaivour tree you’d have to fire those events by code when you want the AI to run.

Curious question, are casting is good to use? performance wise?