How to make widget images change with health?

For a personal project I’m working on, I have this health system in mind where when the player character loses a life, the image in the widget changes. Green is 3/3 health, yellow is 2/3 health, red is 1/3 health. (images are placeholders) What kind of method would I use to achieve this?

Images

Health Variable

Hey there, you can do this 2 ways:

  • Have 3 images and toggle visibility between them
  • Have 1 image and in the code change the brush image

Which do you prefer?

I attempted using 3 images and toggling visibility, but I must have been doing something wrong since I couldn’t get them to work.

Having 1 image and then using code to change brush image does sound interesting tough. I would like to try doing that.

Ok so do the following, select the image on the options on the right create a bind function for the brush. In there you have to create 3 make slatebrush nodes for each of the options and then you’ll just do 2 branches to determine which one to use.

Rather than making the circle coloured, make it white and use this to colour it:

226381-capture.png

This way, you do not need to store/create/maintain multiple brushes/images and/or swap them around. Just pick the colour you want. This will also allow you to animate it easily if you wish so - change the colour gradually, for example.

There are as many solutions to this as there are people. Pick your poison.

No prob :slight_smile:

It works! This is what I did to get it working! Thank you!