Drawing on same HUD from different Blueprints

I have two class blueprints called HUD1 and HUD2.
Both blueprints use DrawTexture to render an image on screen.

How can I make the HUD2->DrawTexture display with the HUD1->DrawTexture ?

I know I can expose variables from HUD1 and Cast_To_HUD1_C from HUD2 but I don’t really want to do that
as it doesn’t fit my design.

The obvious solution is to put everything into a single HUD. That is, however, a last resort as I am trying to avoid a single ‘GOD HUD’ blueprint that gets very big and complicated further down the line.

So basically,
I am trying to create ‘helper blueprints’ each with the ability to draw bitmaps on a single (main) hud.

I’m still not quite sure what exactly you’re trying to do.

It usually makes more sense to put everything which belongs to one HUD in the same blueprint. To prevent it from becoming super big and messy you can use a lot of functions doing most of the actual drawing work.

If you want some basic functionality in several different HUDs which should display something different you can use inheritance from parten blueprints. Simply select the one you want as parent blueprint when creating a new one (instead of actor, character or whatever :wink:

And last but not least if you definitely want it like this you could use interfaces. They are the second method to get variables or call functions in another blueprint besides “cast to”.

Whats exacly point of keeping them sepperated in diffrent classes if you want to use them both. You want to have red and blue square objects that you can spawn in HUD?

Hi Erasio,

" I’m still not quite sure what exactly you’re trying to do. "

(Example analogy), I have three blueprint classes:

Blueprint-1 is the main HUD (set in World Setting->Game Mode->HUD Class)
It uses a [DrawTexture] node to render RED_square.jpg on screen

Blueprint-2 has a [DrawTexture] node for rendering a BLUE_square.jpg

Blueprint-3 has a [DrawTexture] node for rendering a GREEN_square.jpg

I would like to see all three textures (red, blue and green) on screen without having all three DrawTextures located inside Blueprint-1.

I am trying to compartmentalize my HUD functionality.

All blueprints ultimately render to screen, but each blueprint calculates something completely different to the others.
I wish to keep the specialised functionality separate (easier for me to read, manage and debug).

“You want to have red and blue square objects that you can spawn in HUD?”

No object spawning involved (unless I’m misunderstanding your question).
There are only 2D visual elements involved, which represent subsections of the HUD.

As I wrote earlier you could use interfaces but there isn’t really any reason to do so as far as I’m aware.

Splitting functionality up into functions should be more than enough to keep code clean and fairly easy to debug.

I mean you’re essentially doing exactly that but in multiple HUD blueprints.

Unless you want to call those HUD parts independently (for example the right panel should only be visible when X is true) then there aren’t too many reasons not to just use one.

If it’s just one HUD always like that it should be a lot easier to work in one blueprint.

“Unless you want to call those HUD parts independently (for example the right panel should only be visible when X is true) then there aren’t too many reasons not to just use one.”

Indeed, that is one of the reasons amongst others.

Perhaps UE Staff can tell me if Blueprint_A can (in any way) draw to a Blueprint_B HUD or if it’s simply not possible?

Interfaces are not really needed in this case. Interface are for unrealted classes, where this can be done pore cleanly with simple inherence. I still dont uderstand why people so obsesed with interfaces where most of framework API not use them. I wished more people look how classes are made in UE4 and try to replicate how they work

There are no direct ways to do so unless you use inheritance.

You can use (and I feel like I’m repeating myself here) Blueprint Interfaces which are commonly used to pass stuff onto another blueprint or create a masterHUD which has the parts of the HUD which all of your HUDs should share and then switch out the HUD as needed.

But you can not just call the “Event Receive Draw HUD” on multiple classes unless a child class adds a “Call to parent function”.

Any other way of passing on the execution line still works as usual.

Thanks for the info Erasio.

Sorry if I am making you repeat yourself :slight_smile:

Using a Blueprint interfaces is not really an option I want to use so I didn’t comment on it further.
Now I know my objective it isn’t ‘directly’ possible I may have to put everything into the one HUD_BP.

"…unless a child class adds a “Call to parent function”.

I’ll look into that and ‘inheritence’.

Create base class for your hud elements, then based on it create sub classes. In base class you create DrawElement event, where in child classes you use that event to draw element. Base class should also have varables like position and stuff like that so child classes and there object can have its own position. In hud class you add array which you keep elements spawned in object and send drawelement call in all elements in it. Think of it more like you making a framework.

Thanks Shadowriver.

I’ll give that a try.