x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

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.

Product Version: Not Selected
Tags:
more ▼

asked Sep 12 '14 at 07:31 AM in Blueprint Scripting

avatar image

ash22
486 71 62 96

(comments are locked)
10|2000 characters needed characters left

2 answers: sort voted first

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.

more ▼

answered Sep 12 '14 at 02:17 PM

avatar image

Shadowriver
35.2k 921 166 1098

avatar image ash22 Sep 12 '14 at 02:21 PM

Thanks Shadowriver.

I'll give that a try.

(comments are locked)
10|2000 characters needed characters left

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 ;)

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".

more ▼

answered Sep 12 '14 at 11:17 AM

avatar image

Erasio
5.9k 291 86 293

avatar image ash22 Sep 12 '14 at 11:47 AM

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.

avatar image Shadowriver Sep 12 '14 at 12:00 PM

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?

avatar image ash22 Sep 12 '14 at 12:35 PM

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.

avatar image Erasio Sep 12 '14 at 01:13 PM

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.

avatar image ash22 Sep 12 '14 at 01:27 PM

"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?

avatar image Erasio Sep 12 '14 at 01:45 PM

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.

avatar image ash22 Sep 12 '14 at 01:59 PM

Thanks for the info Erasio.

Sorry if I am making you repeat yourself :)

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'.

avatar image Shadowriver Sep 12 '14 at 02:13 PM

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

(comments are locked)
10|2000 characters needed characters left
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question