How to access lvl BP variable from a diffrent blueprint

hello, i have a variable named “Counter” in my lvl blueprint, its an integer and its start from 10 and decreases by time.

rather than printing it i would like to draw text on screen via hud blueprint.

i found couple of forum post but no luck. Direct communications with blue print section of wiki page didnt worked as well. this guy have a solution but i couldnt do it , how to get variable from Level Blueprint into HUD blueprint - Blueprint - Epic Developer Community Forums

how to grab that integer variable ?

thnks.

Hey,

i would say you just store the variable somewhere else.

I good place for that would be the GameState. You can create your own GameState and set this custom BP in your Maps and Nodes (same as GameMode, PlayerCharacter, etc).

Because the LevelBlueprint is just not made to be accessed. You can do this with event dispatchers, but thats more for calling functions inside the LevelBlueprint.

I would really recommend you to put Gameplay related variables that you need to get and display not inside the LevelBlueprint, but in the GameState or PlayerState (PlayerState needs to be set INSIDE the GameMode blueprint under Class Defaults at the top. You can’t set it in the Maps & Nodes, but in the BP itself).

You can easily get the GameState in every other BP by just searching for “GameState” in the context menu.

Hey, I agree it’s simpler to store your variables somewhere else, for single player GameMode is also a good choise to keep variables in, however in a multiplayer game “GameState” is used instead of GameMode, cause only one GameMode exists on the server and clients don’t have direct access. There are always many ways of doing something in UE4. The reason I suggested GameMode is cause as I said only one GameMode and GameState exists in a game and is meant to handle the gameplay stuff and easily communicate between other classes.
It is also nicely explained in this video:


Now to take a step back, it can be done with level blueprint too, like eXi mentioned you can get “GameState” from every other BP, in same way you can get “GameMode” from every BP. So you can use this to communicate between BPs,
for example at some event in your levelBP you would trigger an event or function or update a variable located in GameModeBP, of course GameModeBP can have references to other BPs and it’s contents so that solves your problem.

Here’s another example: