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.
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.
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.
|Disable System||This checkbox will disable the hunger system and is useful in testing/debugging scenarios.||False|
|Max Player Food||This 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 Frequency||This 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 Rate||This value determines how much food the player will lose each second.||0.1|
|Limit Stamina||If 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 Reduction||The size of the penalty applied whilst in starvation mode.||25.0|
|Starvation Damage||This value determines how much damage, per second, the player will receive whilst in starvation mode.||1.0|
|Low Food Visual Effect||The 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 Threshold||Once the player's food drops below this level, the Low Food Visual Effect (if any is set) will kick in.||15.0|
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.