Hunger System

A staple of survival game mechanics, hunger requires players to find and eat food in order to stop themselves starving to death. An incredibly simple mechanic, when used correctly it can be a powerful motivation of the gameplay loop and direct players to always be considering their actions with this in mind. Used poorly, it can result in a horribly annoying drag on gameplay.

Setup

Requirements

The hunger system requires the player controller to have a C_Manager-Health component attached to it to function properly. Optionally, it can also interact with the C_Manager-Stamina component, C_Manager-HUD component and C_Manager-VisualFeedback component.

Initial Setup

After adding the C_Manager-Hunger component to your player controller, the component merely needs to be initialized properly. By default, this is all handled automatically in the included SurvivalController blueprint by the Initialize function, which is run on Event BeginPlay.

If attempting to implement the hunger manager in your own controller, you will be required to run the components function called Event Initialize on startup, parsing a reference to the player controller.

If feedback is desired on the HUD UI or via the visual feedback system, then those respective components must also be attached to the controller and references must be set within the hunger manager. This is also true for the stamina manager if a stamina limitation impact is desired on player starvation. This is all automatically done via the Initialize function within the hunger manager, assuming the required components are attached to it’s parent controller.

Settings

SettingDetailsDefault Value
Disable System This checkbox will disable the hunger system and is useful in testing/debugging scenarios.False
Max Player FoodThis value determines what the maximum player food value can be. In most cases this should not need to be changed for survival game mechanics.100
Update FrequencyThis value determines how many times, per second, this system updates. Higher values will result in smoother mechanics and nicer visual feedback results, but may impact performance (both locally and networked).5
Drain RateThis value determines how much food the player will lose each second.0.1
Limit StaminaIf enabled, when the player enters starvation mode (ie. zero food remaining), they will suffer a stamina penalty which will lower their maximum stamina value.True
Stamina ReductionThe size of the penalty applied whilst in starvation mode.25.0
Starvation DamageThis value determines how much damage, per second, the player will receive whilst in starvation mode.1.0
Low Food Visual EffectThe visual effect (if any) used to indicate to the player low health values. Will come into effect when the player's food crosses the Visual Effect Threshold.Staggered Blur
Visual Effect ThresholdOnce the player's food drops below this level, the Low Food Visual Effect (if any is set) will kick in.15.0

Considerations

Whilst a higher update frequency will result in smoother visuals, both in the visual feedback system and on the HUD, it is important to remember that all of the survival mechanics need to update. In general, the more quickly a stat changes, the more frequently that system should update. Likewise, the systems that are more important to gameplay in your particular game should be given a higher update rate. As an example, usually, survival games have thirst drain a lot faster than hunger. It makes sense, then, to give thirst a higher update frequency than hunger.

Comments

This post currently has 2 responses

  • An observation: Stamina hand hunger run hand in hand, why not simplify things by just using a Stamina/Hunger system combined, to reduce the clutter on the Hud?

    • Whilst some games treat the two stats as a single resource pool, such as with Minecraft, many other survival games have separate stamina and hunger because hunger is usually a slow burn stat, whilst stamina is used with melee attacks, jumps, sprints, etc. By having both in the template, it allows both of these systems to exist, as you can simply disable one of the systems if you don’t want it and hide or remove the HUD elements. Also, the stamina system included has the ability to be impacted by low water, heat, etc. in the template, adding an extra degree of player resource management and risk that wouldn’t really make sense in a hunger system.

Leave a Reply

Your email address will not be published. Required fields are marked *

Sidebar