Issue with reading Variable from another BP

Hi!
I have an issue with accessing a Variable from another Blueprint.

I have a public vector variable in BP-A, and this blueprint is exist on the level.
From BP-B I’ve create a variable with object type of BP-A, from which I’m trying to get that vector variable from BP-A (see attachment).

But when I’m playing the game, I see that vector data is outdated and in editor log I see an error (see a screenshot).

What I’m doing wrong?
Thanks!

Hello,

The issue is probably that you didn’t set the reference to your blueprint in the details panel of your BP-B. You could have many different copies of BP-A, so it doesn’t automatically pick one for you.

Make sure that the variable is already public, find it in the details panel after selecting BP-B in the world outliner, and set it to a reference of BP-A .

Where and how are you setting the variable for your SphereActor_BP? You may have your vector variable on the SphereActor_BP as public As anBerget mentions, you have to set the variable to a reference of SphereActor_BP. You have SphereActor_BP variabl as not instance editable so if another blueprint is trying to set a reference to itself in this blue print you hae screenshot of, it will not be abl to set the variable. As you have it, this blueprint would have to set the variable itself to a reference of the SphereActor_BP blueprint.

If you need to get a reference to the Actor that you have placed in the level, select the Actor in the World Outliner an drag and drop into the blueprint graph and it will give you a reference to it.

Hi Ian,
Your approach is helped partialy, so thanks already! :slight_smile:
The thing is now I’m getting coordinates, but it seems like in one tick I get them, and in the other - an error occurs. That’s really weired behaviour, but it’s like that. So maybe you have any idea what might be the issue.
Checkout on the video:

The problem you’re having is that you’re creating a variable using a BP class type. What you need to do is create the variable in BP-B as a vector and then get a reference to that vector in BP-A.

What you have currently is the same as having a BP_Restaurant with a variable that says where it’s located on a map and then you have a BP_Hamburger and you want to get the address of the restaurant to tell people where to get it; but you’ve put the full business (Building, name, menu, location, staff and everything else) in the address variable of the burger instead of getting a reference to the address variable in the restaurant BP.

Thanks for the picturesque example :slight_smile: However I don’t see how I can get the vector variable directly in BP-B. This variable exist and visible in variables panel only on BP-A.So that’s why in my BP-B I got a BP-A, and then got a vector variable from there. Although it didn’t worked. But after implementing approach which IanBerget proposed, it’s begins to work but partially - on half of ticks I’m getting correct data, but on other half it gets an error for some reason.

What do you mean “Where and how I’m setting the variable?” which one? A Vector? Inside of BP-A.
And I can’t just to drag and drop the Actor from Outliner, because after that it’s just doesn’t appear on BP-B Event Graph.

Hmm,

I don’t see anything immediately wrong in the video that would cause that. Can you confirm that there is not a second PuzzlePlayerCharacter in the World Outliner that is being spawned in on begin play? That would cause the issue you’re seeing if it is the case. If auto-possess is turned off for the original character, then a new one may be spawned in automatically. If yes, the solution is to turn on Auto-Possess Player 0 in the characters details panel.

Gosh! You right! Setting Auto-Posses to Player 0 helped!
But how? I mean, I understand that my GameMode spawns a PuzzlePlayerCharacter, and another copy of it already exist on the level. But how Auto-possesing helped to solve this? :slight_smile:

I’m glad that worked! Auto-possess prevents the second character from spawning. The second character spawns because play mode requires one possed pawn per player. The reason the errors appear for the spawned copy of the character is because the blueprint variable defaults to “none”. There are many different ways to solve that issue. For example, you could use GetAllActorsOfClass on BeginPlay, then get the first element of the array and set your variable with it. I recommend reading up on these articles for more info: https://docs.unrealengine.com/en-US/Engine/Blueprints/UserGuide/BlueprintCommsUsage/index.html

Thanks! :slight_smile: