Help with a Hunger System

Hello everyone!

I’ve been playing around with making a hunger system. I currently have a system in place that depletes a variable called Hunger over time, and when that variable is empty it causes damage to the player. Now, I was able to create a simple healing item just now and it was so easy thanks to the Damage system in UE4. I simply had my character take -30 damage just like in the Blueprint HUD example in the starter content. I would like to do something similar for the Hunger variable I have, however I can’t seem to use the Damage system to help here. My thought was I could use DamageTypes but that doesn’t seem to do what I want. I was hoping to apply damage as a type that would then let me separate damage to my Hunger from damage to my Health.

So what would be the simplest way to achieve what I’m looking to do? Would “Function Interfaces” help out here? What event should I trigger the “health damage” on, since I can’t use “Any Damage Taken” as my event?

So you have basically a separate health system called hunger in addition to health?

If so then you could create it the same as health. Are you doing this all in blueprints or are you using an example as base?

Not sure if this will help, but this is how I’d implement it:

  • Have a variable for Hunger.
  • Each tick, reduce it by an amount.
  • If Hunger < Damage Threshold: subtract player health.
  • If Hunger > Healing Threshold: Heal.

Then, on item pickup:

  • Is food item?
  • Yes: Add to Hunger variable.
  • No: Nothing.

End result should be a gradual decrease in hunger and an eventual decrease in health and healing happening if they’re ‘well fed’. Keep hunger separate as a variable. Items will add to hunger, which in turn, will factor into your “damage vs heal” network section. Using damage for hunger seems unnecessary. I can make an example net work if you like.

Cheers.