[UMG] Dynamic Material Implementation?

Hey all, i’m having a little trouble working on a Uni project, i would like the red within the outline of the character to fade away depending on the health of the character. So as the player loses health it diminishes, however i cant seem to find out how to implement that feature. I have seen the unreal documentation about how i can use a Dynamic material and also the unreal engine video about dynamic materials and how to create them. But what has me stuck is how i combine that with UMG

In the links you can see one is the outline of the character i want to degrade from top to bottom and the other link is the material used for that image brush. I don’t even know if the material is correct for now but just need to see something working before i can solve that.

But i am unsure where to create the nodes i require… do i create them in the Brush binding? or just the widget event graph… kinda lost so help would be great!

Many thanks
Alex

http://puu.sh/hA6c4/c0b44eee87.png
http://puu.sh/hA6eb/b995193542.png

  1. Create a material with the needed paramenters
  2. When you spawn the Character (at begin play event of the character for example), create a Material Instance Dynamic, save it in a variable, and set it as the skeletal mesh’s material.
  3. Change the parameters working on that variable.

Since UMG uses BP too, you should be able to access that variable and modify the material parameters as you wish.

Hey Zamy, thanks for the fast reply! Is it possible for you to give me a visual aid? I understand some of that, but im kinda lost at, “set it as the skeletal meshes material” The skel mesh being the character? I don’t need to change the character material, just the red outline within UMG. Haha can you help clear that up for me, its all new to me
Thanks!

Seems like i misunderstood your question, sorry :slight_smile:
I’m not confortable directly with UMG, but thinking as a normal HUD (drawing on canvas), i would have the character icon as a white asset, then draw it as a whole 1 time in grey (to have the icon “container”), and then draw a portion of it in red, depending on the life.

As example, let’s say we have 50% healt, and the image is 30x70:

  • take the image, draw it in gray
  • take the image from 0:35 to 30:70 (pixel coords), and draw it in red

I think i understand your example, i don’t have much experience with draw on hud method, just the UMG really, just need the red character to represent the amount of health the player has gotten. Seems its been suggested by unreal in a few places but never expanded on. And i have seen no tutorials of this.