How can I access other blueprint's variable in level blueprint

Hi. I made simple blueprint for testing.

As you see, (winkeyofcharacter) is a variable from blueprint (mycharacterblueprint).

When I play testing and press O and L, I can see (winkeyofcharacter)'s value changed in (mycharacterblueprint) and
level blueprint successfully access the (winkeyofcharacter) of (mycharacterblueprint)

but it only checks (winkeyofcharacter)'s default value(false), not changed value(true)

I want to know how to access the (winkeyofcharacter)'s changed value(true)

level blueprint

my character blueprint

When you press the keys, do the strings Print?

did not get what you exactly want but a better solution for such situation is to have a setter function in your characterBP and calling that function from level BP.

add a blueprint function and make an input variable for that and then inside function set your variable using that input. now you can call that function from level BP.

if you want to get that variable make a getter function.

The best case is not to have any controller logic in a level blueprints at all.

Instead, you can use a PlayerController or directly enable the controls handling for a specific blueprint.

If you really need the setup with level blueprint, please check that the MyCharacterBlueprint is directly added to the level in the editor and not re-spawned somehow else (e.g. if it’s a player’s character, then it will be respawned on the game start by the engine, I guess), probably that’s why you get the default value.

So, to handle this, you need to pass the reference somehow to the level blueprint. You can do this through the PlayerController or GameInstance (for this purpose, don’t use it in case of multiplayer) or any other consistent objects.

But, as I said, it’s better not to use Level Blueprint at all.

You never seen this

It’s not really a good way since the get all actors of class may be pretty heavy in case of a lot of actors in scene. It will iterate over ALL actors to find the actors of the requested class.

controller logic is only for testing like print string.
I sovled this problem by setting getplayerpawn and casting instead of referncing character blueprint.
whatever, thank you for answering :slight_smile:

Cool! if it’s about getting the player character then it’s completely fine to use GetPlayerPawn – in fact, internally, it’s exactly the way I suggested – to keep the reference in some known object (e.g. Player Controller).

Yes that’s true, but in this case he want to get his PlayerCharacter Ref so, i guess there will be only one. However this method will not work for a multiplayer game.

solved as above answer reply. but thank you anyway :slight_smile:

i guess there will be only one

Even if there is only one PlayerCharacter, the method will iterate over all actors in the scene at all, that’s what I’m talking about :slight_smile:

Well, I did not think about that, i edited my post.