How can I use a variable from another BP?

In animBP, I want to use a variable from character BP.
i.e.) When I click the screen, a variable is set. If the variable is 1, an animation will be started.

The way to go about this is to just use a single cast to your CharacterBP in your animationBP.

Here I just wanted to show all the variables I have in my FirstPersonCharacterBP that I can call later in the animationBP.

Use a simple cast to access all of the variables you created, in your case either a float or int variable to check when it is equal to 1. The object of this cast here is ‘TrytogetpawnOwner’ which is usually your playercharacter.


I don’t know if you are familiar with state machines but you can set the whatever condition you want in order for you character to transition into the animation you want. In my case here my when I hold down a button, it sets the ‘Firing?’ boolean variable to true which allow my character to enter the shooting animation.

Hope I answered what you are looking for. Hope this helps.

Just make sure to make them public before you could use them in over blueprints. Also make sure that you have the correct instance of the blueprint for you to get references or attributes from that blueprint.

First, really thank you. I’m a noob, but I can slighly understand a cast node thanks to your help.

btw, I tried disconnect original white link and connect to “cast to firstpersoncharacter” just to test.
Print is shown, but the animation is not started.
What’ wrong?..

following image is character BP, widget BP(HUD), anim BP

Thanks to your answer.
I made the variable public, and I followed every steps.
But animation is not working.

I’m sorry it’s a little difficult to understand what you are describing here, but I assume you are referring to the white exec pin. Can’t you just continue the chain? Anyways here is the same animationbp zoomed out so you can see what I connected to what.

From what I understand, TryToGetPawnOwner is used for animation blueprints. In your hud you can just PLayerCharacter as the object in your casting for your character.

Great question! The process is actually pretty simple…

1. The first thing you will need to do is set the variables to public so that they can be accessed by other blueprints. You can do this by clicking the “eye” at the right end of a variable.

Player Blueprint

2. Next, you will need to create a reference to your character inside of the Event Graph (Get Player Character → Cast to “your character here” → promote to variable → “Player”.

3. You now have access to all of the player’s public variables via the “Player” variable.

Animation Blueprint

Let me know if anything still needs clarifying and I’ll be happy to help.

You need to create a variable inside of the AnimBP and then use your player reference to set that variable. You can then use the var owned by the AnimBP to control state transitions.

In widget BP (HUD) case,
when a button is onclicked, a variable is set.
In anim BP, getplayercharacter is not matched, printing warning.

Oh, I succeeded.
I just omit a link… sorry. hahaha.
anyway, thanks your answer again.

Here is a shot that includes the variable created inside of the AnimBP…

Awesome! If it’s not too much trouble then marking this as the answer would really help me out. Thanks and good luck with your project! :slight_smile:

I did :slight_smile:

If you answered my last question, I would be really happy.
As far as I know, I should " get user widget " to object, but I can’t find the node even by searching.

No problem at all. Accessing a widget’s variables is even easier. Just create a variable and set the type equal to a reference of the widget.

Then use the widget reference variable to access vars and set them inside of the AnimBP…