Accessing default variables of child blueprint within HUD

Hey guys.

Lemme start right off with my situation:
I have a class “base_buildable” in my game that contains the variable “image_icon”. I have two children blueprints of this class: “wall_a” and “turret_meele” that both have a defined default valuefor image_icon (Paper 2D Sprites).
My idea was that every child of base_buildable has its own icon that I can define in the editor. Really, this is a constant for the specific entity and these variables are defined as read-only.

Now I want the following code to be “future proof”, so apathic to the types of children that exist at this point. So within my hero character blueprint I have a class reference array of base_buildable that contains the in-play buildables (as I do not want all to be in play at all times). I’ve defined this array as a class reference. This array contains the chosen buildables, up to 8 of them in a certain order.

Now, within my UMG HUD I have 8 images defined and want to bind the images to the default content (i.e. as defined in the editor) of image_icon for the base_buildable children (which are wall_a and turret_meele).

Think of it as selecting buildables from a long list and having the chosen ones displayed in images. The selection should be separate for every player.

So to sum it up:

  • base_buildable has a variable image_icon defined
  • Children blueprints wall_a and turret_meele have different default values for image_icon
  • Player character blueprint has a class reference array to base_buildable, contains turret_meele and wall_a
  • Within HUD, I want to access the default variable content of image_icon of turret_meele and wall_a, but can only access base_buildable default variable content.
  • I want to avoid trying to cast to every single type of base_buildable child in the game to access its default variable, as I want the HUD “script” to just work regardless of how many more buildables I add.

How do I access this default variable content the smartest way?
Hope it’s clear what I mean.
Thanks for reading! I appreciate any suggestions and ideas.

I realize this question is independant of the HUD application. In general, I’m just trying to figure out how to access default variable content of a blueprint child, when I have a class reference array to its parent only.

You don’t need a reference to get an actor’s defaults.

use the GetClassDefaults node and just specify which class

263975-0.png

then when you select the node all the available variables will show in the details panel, you can mark which ones you want to show as pins on the node.

For some reason the texture is not among the variables exposed through “Get Class Defaults”

263995-temp1.png

Make sure you’ve compiled on both sides, sometimes removing/re-adding the node works.

ue4 doesn’t come without its quirks like that. Glad you could sort it out.

That did not work. Seems that class defaults just does not work with anything beyond the standard variable types.

I ended up using a struct and that worked for me, as get class defaults does give you the struct.