I’m having some trouble getting to work. I’ve checked some other people doing , but the nodes they usually use are different from the ones in UE4.5.
Here’s my problem:
I have a parameter that controls a circular life bar and I need that specific parameter to match the health parameter from my character so it displays his health/magic points or anything else, but I’ve arrived to a point where I don’t know how to proceed.
My parameter is called Current Health, so first I create a Dynamic Material Instance from the Construction Script of my HUD and set the material I want as a variable. Then in the Event Graph I get the player controller to cast to MyCharacter to get his HP points and plug them into the value for the parameter I want to modify, but then it asks me for a “Collection”, but in all of the tutorials I’ve seen, they plug a material instance in there and then change the parameter name to whatever it’s called in the material.
I can’t do that. MyCharacter isn’t the owner of HP Dynam Inst, MyHUD is, so that’s kinda impossible.
Anyhow, I did that. I created a new material instance in MyCharacter and then I linked HP Dynam Instance to the set scalar value, but it’s still not doing what I want it to.
DynamicMaterialInstance’s can be made a couple different ways and it is not always clear which to use, the same goes for setting Vector and Scalar parameters. There are 2 separate nodes to be aware of for each of these:
Make sure you turn OFF the “Context Sensitive” option when you are searching for these nodes, and you will find there are 2 of each with the same name. The ones I have selected in the Black comment box are the ones you will want to use in your situation.
I’m sorry, but that still doesn’t do anything. Plus, why would I need to draw it again? I’m already using material in UMG, so the only thing I want is to update the “Current Health” value within the Material, not to redraw it.
Maybe I explained myself wrong.
Thanks, I didn’t know that. I tried using the one in the middle but it’s having no effect. I don’t know what I’m doing wrong anymore. Here my setup with the node you recommended me:
You will want to set up the DynamicMaterialInstance within the HUD construction script instead of the character, and only pass the values to update to the HUD.
I already moved the material instance over to the HUD BP when you told me to. Plus, I’m only updating values from the HUD, but I’m casting the character’s BP because he does have the actual “Current HP” I want to use for the material.
EDIT: Actually, if I draw the material it does work, but my UMG HUD isn’t being updated. I know is like something complelety different, but could you tell me how to update the images in my UMG HUD?
Can you try using a DrawMaterialSimple node instead of the DrawMaterial? The simple version should set the UV’s properly, I can’t see any other reason for not to work. Are you seeing anything on screen or is it just not updating?
I know I’m double posting but I would like someone to possibly answer my second question so I don’t have to create a whole new topic.
How do I update my widget? My material’s values are being updated but the widget itself isn’t being updated, so the bar stays the same.
Sorry for leaving suddenly yesterday, but I found some info on how to do in UMG for you from here:
.unrealengine.com/latest/INT/Engine/UMG/UserGuide/Styling/index.html#dynamicmaterials
It looks like you do need to update on tick and you will probably want to set up a custom event to notify the UMG widget when there is a change, although you could also just reference the variable since it is updating every tick anyways.
You also need to make sure the material is set up with the “Used with UI” option checked (from the link above, scroll up a bit to see the documentation on ).
Ah! Thank you very much! I didn’t know I had to do it that way. It’s kinda annoying but it’s working.
is my final setup, in case anyone has a problem similar to mine.
You probably won’t be able to change the title of thread (I am not sure if forum users are able to do , might only be moderators), but I can do it for you if you’d like? just let me know how you would like it changed and I can fix it up for you!