A base level statistic that comes into play in most game types, stamina can be used to limit sprint distance, control how often a player can jump, add intensity to combat, and more. In terms of it’s existence within the MSGT, it can be connected to most other systems to penalize players for not managing their resources. For example, when you are dehydrated, a lower maximum stamina can be imposed.
The stamina system requires the player controller to have a C_Manager-Stamina component attached to it to function properly. Optionally, it can also interact with the C_Manager-HUD and is interacted with by several other survival system component managers.
After adding the C_Manager-Stamina 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.
In order to actually use the stamina system, you will need to hook it into your movement mechanics. Included in the MSGT is an advanced movements mechanic manager, called C_Manager-Movement. This has options to connect stamina to jumping and sprinting, and should be a good source of reference for connecting the stamina system to your own movements.
Example: Connecting jump to stamina use
In the following example, taken from the C_Manager-Movement, we have the stamina system connected up to the jump mechanic. To begin with, we use the Get Stamina interface reference to get the player’s current stamina. If they have no stamina remaining, we do nothing (Return Node). However, if the player has more than zero stamina, we then allow the jump function to continue, firing off a Consume Stamina node to lower the player’s stamina by the amount specified by the variable StaminaDrainOnJump.
|Disable System||This checkbox will disable the stamina system and is useful in testing/debugging scenarios.||False|
|Max Player Stamina||This value determines what the maximum player stamina 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. As stamina is a highly interactive system that displays very rapidly changing feedback to the player, it is recommended that the update frequency for stamina be significantly higher than most other systems.||20|
|Recovery Delay||This value, expressed as a number of seconds, defines how long the player has to wait, after consuming some stamina, before their stamina will begin to recover.||5|
|Recovery Rate||This value determines how fast stamina recovers and is expressed as a per-second value.||5.0|
|Lower Recovery when Moving||If enabled, then the player will recover a lower amount of stamina whilst moving than whilst standing still.||True|
|Lower Recovery Rate||This value determines how much stamina the player recovers whilst moving if Lower Recovery when Moving is enabled.||2.0|
There are no special considerations necessary for the stamina system.