⮞ Go to NeoFPS.com

    Show / Hide Table of Contents

    StaminaSystem MonoBehaviour

    Overview

    The StaminaSystem behaviour is attached to a character and used to model various fatigue and exertion effects.

    Stamina regenerates at a preset rate and can be drained or modified via a simple API. NeoFPS includes examples such as the FirearmAimFatigue behaviour which drains stamina while aiming down sights, or the DrainStaminaBehaviour and ModifyStaminaBehaviour motion graph behaviours which can be used to drain stamina over time in a specific motion state such as sprinting, or on entering a state such as jumping.

    Stamina can be used to drive the BreathingEffect procedural animation on weapons. You can specify the breathing rate and strength based on fatigue using animation curves for each.

    Stamina can also be used to control movement speed, slowing the character as they get tired. There is an optional exhaustion setting which can be tied to the motion graph to prevent the character from sprinting once they reach the exhaustion threshold, and re-enable sprinting once stamina has recovered to a certain point.

    Inspector

    StaminaSystem

    Properties

    Stamina

    Name Type Description
    Stamina Float The current stamina of the character. This acts as the starting stamina and changes at runtime.
    Max Stamina Float The maximum stamina of the character.
    Stamina Refresh Rate Float The rate that stamina increases over time when no drains are applied.

    Movement Speed

    Name Type Description
    Affect Movement Speed Boolean Should the stamina system modify movement speed based on current stamina. The other settings will be hidden if this is false.
    Min Walk Multiplier Float A multiplier applied to the walking speed at minimum stamina.
    Min Sprint Multiplier Float A multiplier applied to the sprinting speed at minimum stamina.
    Min Crouch Multiplier Float A multiplier applied to the crouching speed at minimum stamina.
    Move Speed Curve Unity AnimationCurve A curve that defines the character speed based on stamina. The X axis is the normalised stamina (stamina / max), while the Y axis is the min to max lerp value (0 = min, 1 = max).
    Walk Speed Data String The name of the motion data property on the motion graph that defines walk speed.
    Aim Walk Speed Data String The name of the motion data property on the motion graph that defines walk speed when aiming.
    Sprint Speed Data String The name of the motion data property on the motion graph that defines sprint speed.
    Aim Sprint Speed Data String The name of the motion data property on the motion graph that defines sprint speed when aiming.
    Crouch Speed Data String The name of the motion data property on the motion graph that defines crouch movement speed.
    Aim Crouch Speed Data String The name of the motion data property on the motion graph that defines crouch movement speed when aiming.

    Breathing

    Name Type Description
    Breathe Slow Interval Float The time in seconds between breaths (when breathing slow).
    Breathe Fast Interval Float The time in seconds between breaths (when breathing fast).
    Breathing Rate Curve Unity AnimationCurve A curve that defines the breathing rate based on stamina. The X-axis is the normalised stamina (stamina / max stamina), and the Y-Axis is a lerp between slow and fast breathing rate (0 = slow, 1 = fast).
    Breathing Strength Curve Unity AnimationCurve A curve that defines the breathing strength based on stamina. The X-axis is the normalised stamina (stamina / max stamina), and the Y-Axis is the strength of the character's breathing (0 = non-existant, 1 = heaving/panting).

    Exhaustion

    Name Type Description
    Use Exhaustion Bool Should the character suffer an exhaustion effect on hitting a specific stamina threshold. The other properties will be hidden if this is false.
    Exhaustion Threshold Float The stamina level below which the character will become exhausted.
    Recover Threshold Float The character will stop being exhausted once their stamina has recovered above this value.
    Exhausted Motion Parameter String The name of the switch motion graph parameter that the graph uses as a condition for preventing sprinting.
    Sprint Motion Parameter String The name of the switch motion graph parameter that the character input handler sets to tell the motion graph to start sprinting.
    On Exhausted UnityEvent An event which is fired when the character hits the exhaustion threshold.
    On Recovered UnityEvent An event which is fired when the character recovers from exhaustion.

    See Also

    BreathingEffect

    Motion Graph Parameters And Data

    Modular Firearms

    Unity AnimationCurve

    Back to top Copyright © 2019 Yondernauts Game Studios Ltd
    Generated with DocFX