Replicating Metroid Style Energy Tanks

Imgur

This post explains my dilemma but i’ll list it here also:

  1. I have a health system where the player picks up “energy tanks” similar to Metroid. The player’s health value stays at a static 100 value and maxes out at 100 (i have two floats. Current Health and Max Health for these values.)

  2. When you pick up an energy tank, it adds to an integer value which maxes out at 10. (There’s 10 energy tanks in the game) I have it setup to where when you take damage and your current health reaches below zero, it checks to see if you have any energy tanks in the integer value.

  3. If that number is higher than 0, then your health needs to reset back to the max health value of 100. Each time you pick up an energy tank actor, it adds +1 to both current energy tanks, and max energy tanks (which have their own UI elements. An empty orange square for max energy tanks and filled in orange square for current energy tanks)

  4. But my issue arises when my player takes damage or receives health. I have it to where you take damage, and then it resets the health back to 100% and takes -1 away from your current energy tanks, and adds it when your health goes over that amount but I want it so when the number of health taken away is greater than the current value, it takes that left over value and then adds it to 0 after setting the health value to 0.

  5. I also want it to do the same in reverse with healing. When you receive health higher than the max of 100, it will add to your energy tank count and whatever is left over from health given past 100 is added to 0 on the next “health bar”.

  6. I have it setup to where you pick up the tanks, get the UI elements, and then taking over 100 damage subtracts an energy tank and resets your health back to 100 but I need it to do what I said above. Here’s all my screenshots of my blueprints.