Download

Sending a variable from your character to the HuD and doing some HuD Stuff Tutorial

Since a lot of people have been asking about this (myself included), I figured I’d try my hand at a simple blueprint tutorial that can help get people started. I apologize in advance for my nervousness as this was the first time I’ve done a tutorial with my voice over. In it I’ll cover sending a variable to the HuD, creating a basic parameter in a material (to animate color), and animating the HuD bar to drain and refill as your variable gets used up.

Hopefully I didn’t make any major mistakes, and that this is helpful to those who were as confused as I was :o

https://youtube.com/watch?v=KqkszRTeDoM

Nice tutorial! I mentioned it in the comment I left on the video, but for anybody reading the thread wondering: Screen Size can be used to place HUD items rather than giving absolute values that will only look right on a single resolution, whilst dividing the screen size and using those values should make your hud work across all resolutions.

Ah thanks for the input! Now I know, and I’ll add a lil explanation box on the video.

thanks for posting this, might help me with my health bar:)

I hope it does :slight_smile:

I don’t know what it is, but something about the UE4 just gets me in such a sharing mood. Spread the love guys, assist your fellow Devs! lol.

Hi,

great vid, helped me out a lot.

Just one thing, you should try not make member variables of classes public, because then everybody could use the variable and manipulate it.
To be on the save side make the membervariables private and use setter and getter funktions if needed.

You could make a public Get_Stamina() funktion in MyCharacter and then use it in your HUD class to return the stamina values from your character.

This way you can read the stamina values with no problems and at the same time the stamina values in MyCharacter are save and can only be changed by the Character himself.

well fingers crossed between your tutorial and the “content examples”

quick question: would the bar work in increments of 10/20/30…ect? so it takes off a set amount each time instead of draining.

that’s what makes epics forums the best:)

Ah thanks for that, it may help more people who come across this.

Hmm, I believe it already does? Unless I’m misunderstanding you that is, it currently does work with removing set amounts of in my case stamina. Notice when jumping it drains a set amount all at once rather than a constant drain like when sprinting.

well I want to make a health bar so the player starts with 100 health and then have objects that inflict set amounts (10/20/30) of damage and a couple of health pickups that add set amounts of health.

Yeah I believe this should work for you then. Think of the lerp for the width in the HuD as a number (your variable) between 0% and 100% (0% being 0 width and 100 width being 100%, if that’s what you set it to) . It’ll update accordingly regardless of if you decrease it by a set amount or by a constant stream.

Thank you so much for the video!

So I have followed your tutorial completely and everything seems to look exactly the same except for the variable I used from my particular character blueprint, but for some reason, I cannot get the HUD Bar to show. I’ve played around with the Draw Material values and the Screen size variable a bit but nothing seems to work. Do you have any ideas as to why I’m experiencing this problem? Thanks!

EDIT: Nevermind! Haha I’m so dumb, I just didn’t have the HUD that I created selected in my GameMode. facepalm

Yeah I just kinda assumed that people would have done that already, I’ll have to add that in to it to avoid anyone else getting confused lol. But yeah glad it helped ya :slight_smile:

Thanks, this helped me a lot. I could not make HUD communicate with my character, that one detail: “cast to MyCharacter” is what was missing for me.

Hi Wisdomcube2000,

In your Video
you call [Create Dynamic Material Instance] from your construction script.

I created a new First Person Blueprint project (UE4.6) and went to the construction script of MyHUD,
but I cannot access the [Create Dynamic Material Instance] node that you have.
It is not in the context wire list, or the r-click list.
it is in the library Palette but it cannot be dragged into the graph as they are not compatible.

How did you do it?