UE4: How to make NPC HUD using it's variables as text

38053-rpg.png

Guys I am trying to create an RPG battle system much like the example above. I have figured out how to make widgets that display a HUD on the level blueprint (so that it appears on the screen as opposed to being in the character blueprint) for the PlayerCharacter but I cannot seem to figure out how to do the same for NON PlayerCharacters?? Any ideas how to make a HUD like this for NPCs that display on the top left like the example above?

Thanks!

Sin

,

Thank for the advice man but im still confused as to how to go about getting the Monster variables (such as Health) into the HUD since it wont allow Floats into a text block and only seems to allow me to use the Player Character and not other Characters/Actors. Do you have an example or know of a tutorial perhaps?

Thanks again!

Sin

First of all, don’t use Level Blueprint to create systems, level blueprint is purely for level scripting, use more global like GameMode, it’s class dedicated for general gameplay control. Create a class that manages party or implement it in GameMode and by that you will be bale to access all characters from it and draw HUD properly

1 Like

For anyone else wondering about this, I found the following information straight out of the UE4 documentation under Casting:

"Below are a few examples of when Blueprint Casting could be used:

◦Passing player or enemy health from a Character Blueprint to a HUD or Widget Blueprint to display the value on screen.

BINGO! This is EXACTLY what I am trying to do…

  1. Create an enemy character and give it a float variable called “Health”
  2. Create a HUD or Widget to display this float as text (not a progress bar) to the top left of the game screen

How do I do this Everything I have tried will not work. Please see my screen shot above as an example as to what I want to do.

Thanks so much for any help.

Sin

Well actually its easy. You can convert the float to a string (the text) which you need, as i suppose:

Create a new blueprintclass for your NPC, like you can see in the picture (the class I made is called Example Class)

Then inside of that class create a float variable, name it HP or Health for example, and make a new function. You can call it GetHPAsString or sumthing. I did that as you can see here:

This will convert the NPc’s HP float variable to a string.
Then you can call it like this:

And finally you have the result as you can see in the top left corner of my viewport. Dont forget to drag and drop your BlueprintClass inside the editor

Awesome i’ll give this a shot and see if this helps me find the solution. Thanks dude!