I hope I’m not asking for too much, but I was wondering how I make a heart-based health not based on the Legend of Zelda.
What I mean by non-Zelda is that in the Legend of Zelda games, the heart-based health system uses fractions, which results in things liking having 3 full hearts & 1/4 of a fourth heart, whereas in my own game I simply want to use whole numbers i.e. having three hearts means that the player can only take three hits before they die and not any other number of hits.
Unfortunately, every tutorial I’ve encountered so far in making a heart-based health system has been on Legend of Zelda’s, such as this one, or this one, and finally, this one. In theory, I could just modified one of the blueprint setups from one of the linked tutorials but I’m not confident enough in my own abilities to do so without creating a disastrous mess.
Something else that needs to be taken into consideration is that the health system needs placed into the Game Mode blueprint. The reason for this is because in the game I’m making, the player will able to switch between multiple different characters, all of which share the same health pool, and I assume that if the health system is placed within my only playable character I’ve made so far’s blueprint, then that health bar will then only apply to that character and not the other ones I intend to incorporate?
Hopefully, someone will be able to help me out with this particular endeavor.
For something that simple you can add 3 images to a widget’s horizontal box and keep the hit points in an int variable. Player losing/gaining health hides/shows a heart image widget (or changes its colour).
You could call something like this in the widget with health values 0-3:
This will colour the widget based on the int value; you could use white hearts here and alter their colour like so. Not the best setup ever but perhaps it will jump-start something for you. [HR][/HR]
For something more complex, have a look here:
Man, its been far too long since I’ve approached this topic but anyways, since the last time I responded to this topic I’ve made a little progress but I still have a ways to go from getting the heart meter working as intended.
I managed to get the hearts to display on my game project’s HUD but unfortunately in its current state the heart meter doesn’t do anything as I haven’t been able to figure out how to tie the heart meter to my health system I already have in place.
Not helping matters is that when I initially created this topic I forgot to mention some critical details on the heart meter on I wanted to create.
Firstly, I need the heart meter to be upgradable, expanding from the initial three hearts to a total of nine, like this:
And secondly, when the player takes damage I want to swap out the full heart image with a empty one:
My current heart meter allows displaying additional hearts but as I’ve already mentioned I don’t know how to connect it to my current health system.
As for the second issue, all the tutorials I’ve seen so far for heart-based health meters use a health bar-like setup using a single heart image that is modified to indicate damage, as opposed to what I want to do with using two separate images: a full heart & a empty heart, and swapping between the two of them as needed. This setup might seem kind of pedantic but I also wanted to use this setup to also make a collectible display similar to the one in the New Super Mario Bros. games:
In your setup you have the For Each Loop node connected to a custom event refencing a ‘Health’ integer variable. I assume the ‘Health’ integer variable is supposed to be analogous to the ‘Current Health’ variable I have in my player’s damage setup but I’m not entirely clear as to how that’s supposed to work as I have to create a new variable in the Input tab and I’m not sure how this new variable is supposed to interact with the ‘Current Health’ variable in the damage setup.
Meanwhile, in the other blueprint, the other person instead gets a direct reference to the ‘Current Health’ variable connected to the ‘Greater Than’ node. Unfortunately for me though, for some reason I can’t replicate this as trying to ‘Get Current Health’ instead results in this instead:
Not helping matters is that its been a while since I’ve done anything with Unreal so I’ve forgotten a lot about what I’m supposed to do in matters like this.
In addition to my above confusion, I’m also having problems with changing how the hearts are displayed. The problem I’m having stems from the fact that I can only attach the Heart widget to Set Brush from Material which is a problem because the actually heart images are textures not materials. I can connect the Select node to Set Brush from Texture but not the Heart widget, as the Set Brush from Texture node says the target needs to be a “border”, whatever that means. Whereas I can connect the Heart widget to Set Brush from Material but not the Select node, as the textures are incompatible with that node. The Set Brush from Texture Dynamic node does allow me to connect the Heart widget to it but evidently “2D textures” are incompatible with “2D dynamic textures”, so I guess that’s not an option.
I tried creating materials with the two heart textures so that I can just use Set Brush from Material. However, I can’t figure out how to properly set them up, as right now the heart materials just appear as black squares.
Here’s something a little more complete, hope this will either inspire or, at least, push you in the right direction and clarify some of the communication mechanics between the blueprints:
Consider this being the wHeart widget:
– it keeps track of its own state via the isFull variable
– the Set State custom event switches the images around
– this widget is the equivalent of a single heart either being full or empty
Another widget - wHealthBar is made out of many wHearts:
– Set Health creates the desired number of wHeart widgets, adds the to a wrap box and stores them in an array; the latter is done to avoid casting later on
– Update Health operates on the wHeart widgets and sets their isFull state according to the player’s health
– Increase Health Pool; each time it’s called, it creates and additional wHeart widget, visualising the now larger health pool
And this is the player:
– health is tracked with 2 variables: HP_Current & HP_Max; both set to 6
– we add the wHealthBar widget to the screen, store its reference; call SetHealth (see above) to visualise the starting health pool
The 1, 2, 3 represent operations on the health pool and would normally be called as the player interacts with the world, here to simulate those evets:
1 damages the player
2 expands the health pool
We update the display after they’re called, feeding the widget with a new HP data.