Download

Passing Variable from level blueprint to Hud Blueprint

I have a variable I can log (print) to the screen in my level blueprint. I am learning about the HUD, and I want to take the same variable and output there. I can’t access the variable from the level blueprint in the HUD blueprint.

Do I have to cast it from the level blueprint to something the HUD will see?

What I have (real basic, just learning, don’t flame) in my level blueprint:

You can see that in the HUD event graph, I have the draw text function, but can’t set the text pin with the variable from the level blueprint. It’s just not showing up.

Can someone help?

Thank you,

The Level blueprint has a GetHUD. You will need to use that, and cast the result to the type that your hud is.
To do this right click on the graph and type GetHUD into the search box. Drag from the output pin of the node this creates and type cast into the search box.
You should see a cast to the type that is your hud. (So if your HUD is MyHUD there will be a Cast to MyHUD)

From this node you should be able to drag from the output pin and access the variables in your HUD class.

Ok - I understand what you said Bruce - thank you. I think I can access the level variable in the HUD, but how do I do this final wire hookup so that the variable is only called when I enter a box trigger? I could hook up the box trigger to console log something, but now I want to have the same effect but to the HUD.

I have this, tried to hook it up but keep getting errors on compile.

Thanks for the help,

Not sure if you got this to work yet since it hasn’t been updated, but hook up a getPlayerController into your getHUD.

If you want to do this for a trigger box you would probably be better off creating a blueprint based on a trigger box and putting the event in there.
As LevonChurch mentions you can get the HUD via GetPlayerController