Making MyCharacter variable visible to UMG widget blueprint

Hi,

I’m trying to gain access to a default MyCharacter blueprint user added variable, in a UMG widget blueprint - I’m following the UMG tutorial:

The project was set up from the default Third Person blueprint project template and no other changes have been made other than as below:

I opened the pre-generated MyCharacter blueprint, and added new variables “Char_Health” and “Char_Energy” (floats), gave them default values, then saved and compiled. I then created a new Widget blueprint, added a progress bar as per the tutorial and in the progress bar details, selected “percentage > bind”. In the graph view that opened, I added and connected a “Get Player Character” and a “Cast to My Character” node as per tutorial image. At this stage, I can’t seam to find the MyCharacter blueprint variables that were added. If it makes any difference, the “Cast to My Character” output pin shows “As My Character”, not “as My Character C”. I’ve tried saving, compiling the widget, and selecting “Show Inherited Variables” and setting “Context Sensitive” on and off. Does anyone know what I’m missing?

Any help would be great…

What I have done is to have made a variable and set its type to “My Character” and on the widget contruct:

Although Bonny’s method works, but it is better to have a blueprint with interface setup.
Otherwise anytime you update your character, your widget blueprint will need to be recompiled.
And if you go along this path, you might stumble upon circular reference, which is a big PITA to solve properly.

Hi,

Thanks for your replies. Do you have any links on how to set up a blueprint with interface setup? I’m kind of assuming the tutorial doesn’t work and is missing a step as I followed it again exactly from the beginning, and get the same result…

There must be a *standard * way of creating a HUD that displays a main characters health and other stats, and of creating a GUI control panel that allows the user to click a button to make a character perform certain actions.

Also, when I compile the blueprints, I get the error message “Error this blueprint (self) is not a MyCharacter_C, therefore ‘Target’ must have a connection”. I get a similar message inside the widget blueprint. Does this have this something to do with having to make an object instantiation of the blueprint (similar to C++ where you create a class object instance from a class definition template)?

Any help would be really appreciated,
Thanks,
Bruce

Hi Mach45,

You can find more information on setting up blueprint interfaces here:

https://docs.unrealengine.com/latest/INT/Engine/Blueprints/UserGuide/Types/Interface/UsingInterfaces/index.html

What I personally followed to achieve to display health and whatnot is the “UMG Inventory in UE4” on the official UE channel (can be found here: https://www…com/watch?v=RQm6cm05SLc)

I recommend watching the whole series just as not to miss something but I believe the main UMG part start at approximatly 0:52 in part 3 (https://www…com/watch?v=VjKY6z6uP0M#t=52)