How to access a variable in a class blueprint from an animation blueprint?

Hello,
I’ve been struggling with this and I couldn’t find an answer when I googled and searched here,
I simply have a public boolean variable called “isAttacking” in my pawn class blueprint that determines if the player is attacking or not which should affect the animation.

Problem is that, I can’t access it from my animation blueprint’s EventGraph…I tried using “Get Player Pawn” and trying to access it from there with no luck…How do I access that variable from there?

1 Like

Try using the Try Get Pawn Owner node! :slight_smile:

Still no luck ):

This post has steps for accessing a variable in your character/pawn BP from your animation BP:

The example uses “Get Pawn Owner” and casts to the specific Character BP from there. If that’s failing for some reason for you (I don’t think it should…), I would try ‘Get Owning Actor’ as mentioned above.
Hope that helps!

Howdy!

Can you Get Player Character and cast that to your Character Blueprint? From there you should be able to drag off the Character Blueprint and access your variables.

-W

Or this. :slight_smile:

Try Get Pawn Owner will try to get owner of a specific pawn ; p

Get Owning Actor will return current actor that animation is attached to
https://docs.unrealengine.com/latest/INT/API/RuntimeModules/Engine/Animation/UAnimInstance/GetOwningActor/index.html

Altearnativly you can do in opposite way and acces animation blueprint from blueprint by get anim script instance on your skeletal mesh component and set varables in animation blueprint

That worked for me! I used a Begin Play to cast the skelmeshcomponent into the animBP, validated it and then used jump to set a public bool from my animBP graph.

Huge thanks! This was kicking my ■■■ all last night.

Pardon me, I need help with getting the value of the variable from MyCharacter “Is Punching?” to CharacterAnimBP. But the “As My Character” in “cast to MyCharacter” does not connect to “Get” variable of “Is Punching?” as you can see in the image.

This was my solution (working on an actor based object).

  1. Get the owning component from the anim instance
  2. Get the owning actor from the component
  3. Cast it to the blueprint type I know it to be
  4. Get the variable
  5. Evaluate the animation (in this case a single frame animation)

Did you ever get a solid working solution for this. I am new to UE4 and have the exact same scenario you outlined. Have been at it for a few hours now trying to get this to work. Would greatly appreciate if you could post a quick screen shot of your solution? Pay it forward bro…

In case anyone is unsure what to plug into “get owning actor” like I was, you get a reference to “self”.