how to get variable from Level Blueprint into HUD blueprint

Hi all, I’ve been reading about transferring variables to and from blueprints for the last couple of days and haven’t heard a definitive answer for this yet: Is it possible to refer to a variable that is in the Level Blueprint?

I did all of my visual scripting in the Level Blueprint (as opposed to creating an actor blueprint), and now I’m trying to build the HUD blueprint so that it prints those variables to the screen. I was hoping that I could just say, “This variable in this Level Blueprint will be able to be referenced in another level blueprint, or in the HUD blueprint”, but so far, all of the techniques I’ve tried seem to only work with non-level-blueprints.

Is what I’m trying to do impossible with the Level Blueprint? I’m just trying to decide if I should give up searching for a way to do it, or just go ahead and rework the way I’m blueprinting…

Without trying it myself to see (not at the editor at the moment), I can’t say for sure… but you should be able to expose those variables either with the little “closed eye” to the right of them, or down in their details there should be an “expose variable” check box… Once that’s done, I would think you can do a “get” on them in other blueprints, since they should become global to the level…?

If that’s what you tried and it doesn’t work, then I’m not sure. I could try to play with that when I get back to my comp… unless someone else answers first :smiley:

Cool thanks.

Oohh, the fact that you think I “should” be able to is nice to hear. I did investigate the “closed eye” things for a while. I opened them, and then tried to jiggle a few things here and there. I don’t think I checked any boxes in the details though, so I’ll have to look into that tomorrow (my home desktop and laptop are evidently too ****** to run UE4).

I was actually able to place a variable from an actor blueprint into my HUD blueprint by adding a variable and looking for the “objects - nameofblueprint_C” stuff. It didn’t actually work the way I wanted it to but I was happy to see the possibility. What I was confused about was that I didn’t see “objects - levelblueprint_C” or anything like that, and realized I may have screwed myself…but then I was like, "wait, it’s a freaking variable, I should be able to get it somehow right?

Anyway, long way of saying thanks!

Well, not to burst your bubble… but the direct method I was thinking about doesn’t work… you can’t access the level BP from any other BPs directly, so the “expose variable” thing is out. I did find several other suggestions of ways to do that sort of thing, but they were all clear as mud (and I don’t have time to try and sort them out)…

But, I’ll be checking back here to see what develops, as I’m sure at some point I’m going to need to transfer data between levels somehow, which kind of requires being able to chat with level BPs in some way…

Perhaps you could use the new Blueprint Structs we are getting in 4.2 for this?

Clear as…

Well at least I’m glad it’s not just me. I did see a few pages that looked like they might have held clues, but after reading, re-reading, attempting in UE4, etc, I finally succumbed and submitted the OP. When I figure something out, I’ll post here.

Have you tried using blueprint interfaces to have your level bp talk to your HUD? When the cars on your level bp are update, you could have a BPI at the end send a message to your HUD with the value of your var. it’s basically the reverse of what you asked for, but it is at least getting info from the level blueprint to your HUD.

Unfortunately, there isn’t a proper way for other Blueprints to access variables in the Level Blueprint at the moment, because you can’t really get a reference to the Level BP to use as a target. It’s a good place for putting sequences for level-specific things like opening doors, spawning enemies or playing cinematics, but isn’t intended to contain gameplay logic - that kind of thing would usually be better off in the GameMode Blueprint.

That said, the Level Blueprint can send information to other Blueprints, so in the case of wanting to update what’s displayed on a HUD, you create the variables you want in the HUD Blueprint and set them in the Level Blueprint. It would look something like this in the Level BP, depending on what specifically you want to do:

In this case, I added variables for player health and score to my HUD Blueprint, and am able to set them in the Level Blueprint by casting to my player’s HUD in order to access its stuff. You could also do this to call custom events you make in your HUD, play timelines, and so on. Does that seem like it’d cover everything in your case?

Another method is to create custom events in your Level BP and call them from other Blueprints using the “Execute console command” function, which I think can be called from any Blueprint. Just type in “ce (event name)”, the in the function’s command field, and it should trigger the matching custom event in the Level BP. It’s not really how you’re supposed to make a game, but can be useful if you really need to trigger something in the Level Blueprint and other methods aren’t working out.

Thanks Thomas! That does seem like it will work for me. You illuminated a lot for me with your reply, I appreciate it immensely.

I did find references to BPIs, but hadn’t figured out how to use them yet. I stumbled through trying to create them and became completely lost. I think you simplified the process in your reply enough for me to give it another go, though, so thanks so much!

Awesome, thanks for the heads up on blueprint structs (or just for making me look up what a “struct” was in general). I’m a self-taught hack when it comes to programming/coding, so there’s a lot I don’t know, I really enjoy learning new terms/concepts in these forums. Thanks.

I know this is an old thread but I just worked out a solution for a student asking a similar question. He wanted to get an array of waypoints which was stored in his level and pass that to an actor.

I did this by using an event dispatcher on the actor class. The dispatcher is bound to an event in the level blueprint which sends the array to the actor upon request.

This is my Level Blueprint:

This is my Test Actor Blueprint:

The Event Dispatcher (Request Array) has an input called Instigator which is an Actor Reference.

The print array event is simply there to confirm that the array has been received correctly.

I have no idea if this is efficient or the “correct” way but it works, so I hope this helps someone.

//disclaimer, I realise I’ve used a bool array but this was a quick build solution for an example.

Regards,

Stu

I can’t duplicate this. Can you go into a little more detail? I dont know how you got the instigator pin in your custom event Send Array

I know this was a while back but when you create an event dispatch, you can click on it and it shows details in the details panel where you can add inputs. He added that instigator node.