MotionSprintingComponent
Manages sprint speed enhancement, stamina/endurance system, and camera effects during sprinting with full GAS integration. Provides input handling, state management, and networked multiplayer support.
Requirements
- Character with standard
UCharacterMovementComponent - MotionPlayerState configured in GameMode
- Gameplay Ability System (GAS) initialized
- Enhanced Input System configured
- Gameplay Effects:
GE_Motion_SprintSpeed- Modifies walk speed for sprintingGE_Motion_SprintStaminiaDrain- Drains stamina while sprinting (optional)GE_Motion_SprintStaminiaRegen- Regenerates stamina when not sprinting (optional)GE_Motion_SprintStaminiaRegenDelay- Blocks regen after exhaustion (optional)GE_Motion_WantsToSprint- Grants wants to sprint tagGE_Motion_Sprinting- Grants sprinting state tag
- Gameplay Tags:
Motion.State.WantsToSprint- Player input to sprintMotion.State.Sprinting- Active sprinting stateAttribute.Movement.WalkSpeed- Movement speed attributeAttribute.Movement.Stamina- Stamina attribute (if using stamina)
Installation
- Add
UMotionSprintingComponentto your Character Blueprint or C++ class - Configure the component properties in the Details panel
- Set the
SprintingTagEffecttoGE_Motion_Sprinting - Set the
WantsToSprintTagEffecttoGE_Motion_WantsToSprint - Configure stamina effects if using stamina system:
- Set
SprintStaminaDrainEffectfor stamina consumption - Set
StaminaRegenEffectfor recovery - Set
StaminaRegenDelayEffectfor exhaustion cooldown
- Set
- Bind sprint input action in Enhanced Input or through component


Functionality
Core Sprint State Machine
Sprint Update Flow
Expandability
The MotionSprintingComponent provides extensive virtual functions for customization:
Core Sprint Functions
| Function | Parameters | Returns | Use Case Examples |
|---|---|---|---|
SetWantsToSprint() | bool bWantsToSprint | void | • Add cooldown timer • Check prerequisites |
GetWantsToSprint() | None | bool | • Query sprint intent • UI state display |
IsCurrentlySprinting() | None | bool | • Check active sprint • Animation triggers |
CanStartSprinting() | None | bool | • Add custom conditions • Equipment checks |
State Management Functions
| Function | Parameters | Returns | Use Case Examples |
|---|---|---|---|
UpdateSprintingState() | float DeltaTime | void | • Custom state logic • Add transitions |
InitializeComponent() | None | void | • Additional setup • Cache references |
HandleSprintInputStateChange() | bool bPressed | void | • Input processing • Toggle logic |
PrintDebugInformation() | None | void | • Custom debug display • Performance metrics |
Stamina System Functions
| Function | Parameters | Returns | Use Case Examples |
|---|---|---|---|
GetStaminaFromGAS() | None | float | • Custom attribute source • Apply modifiers |
GetCurrentStamina() | None | float | • Normalized value • UI display |
UpdateStamina() | float DeltaTime | void | • Custom drain rate • Conditional consumption |
UpdateStaminaWithGameplayEffects() | float DeltaTime | void | • GAS integration • Effect management |
OnStaminaAttributeChanged() | FOnAttributeChangeData& | void | • React to changes • Threshold checks |
OnStaminaDepleted() | float CurrentValue | void | • Exhaustion logic • Apply penalties |
Speed Modification Functions
| Function | Parameters | Returns | Use Case Examples |
|---|---|---|---|
ApplySprintSpeedModification() | None | void | • Apply speed boost • Stack with buffs |
RemoveSprintSpeedModification() | None | void | • Remove speed boost • Clear effects |
GetCurrentMovementSpeed() | None | float | • Query current speed • Calculate multipliers |
IsActuallyMoving() | None | bool | • Check velocity • Validate movement |
Camera Effect Functions
| Function | Parameters | Returns | Use Case Examples |
|---|---|---|---|
StartSprintCameraEffects() | None | void | • Apply camera shake • FOV changes |
StopSprintCameraEffects() | None | void | • Remove effects • Smooth transition |
Input System Functions
| Function | Parameters | Returns | Use Case Examples |
|---|---|---|---|
OnInputStarted() | FInputActionValue& | void | • Handle press • Buffer input |
OnInputCompleted() | FInputActionValue& | void | • Handle release • Toggle mode |
BindSprintInput() | UInputAction* | bool | • Bind to action • Setup input |
BindSprintInputWithComponent() | UInputAction*, UEnhancedInputComponent* | bool | • Explicit binding • Custom component |
Blueprint Events
| Event | Parameters | Use Case Examples |
|---|---|---|
OnSprintStateChanged | bool bIsSprinting | • Sound effects • Animation triggers |
OnSprintStaminaDepleted | None | • Exhaustion VFX • Breathing sounds |
OnStaminaFullyRecovered | None | • Recovery notification • Enable UI |
OnStaminaChanged | float NewStamina, float MaxStamina | • Update stamina bar • Warning indicators |
Network Functions
| Function | Parameters | Returns | Use Case Examples |
|---|---|---|---|
ServerRequestSprint() | bool bWantsToSprint | void (RPC) | • Server validation • Authority check |
Configuration
Sprint Settings
| Property | Type | Default | Description | Range |
|---|---|---|---|---|
| SprintWalkSpeedModifier | float | 300.0 | Absolute walk speed value to add when sprinting | - |
| bRequiresContinuousInput | bool | true | Whether sprinting requires holding input or is toggle | - |
| BaseWalkSpeed | float | 600.0 | Base walk speed for sprint multiplier calculations | 100.0 - 2000.0 |
Stamina System
| Property | Type | Default | Description | Range |
|---|---|---|---|---|
| bUseStaminaSystem | bool | false | Whether sprinting is limited by stamina | - |
| MinStaminaToSprint | float | 1.5 | Minimum stamina required to start sprinting (raw value) | - |
| MinStaminaToStopSprinting | float | 0.25 | Minimum stamina to continue (hysteresis) | - |
| MinSprintVelocity | float | 50.0 | Minimum velocity required to consume stamina | 1.0+ |
| RegenDelayDuration | float | 2.0 | Duration to block regen after exhaustion | 0.0 - 10.0 |
| bForceReleaseOnStaminaDepletion | bool | true | Force input release after depletion | - |
Camera Effects
| Property | Type | Default | Description | Range |
|---|---|---|---|---|
| SprintCameraShake | FStructMotionCurve | - | Camera shake curve during sprinting | - |
| bApplyCameraShake | bool | true | Whether to apply camera shake | - |
GAS Integration
| Property | Type | Description |
|---|---|---|
| SprintSpeedEffect | TSubclassOf<UGameplayEffect> | Effect for sprint speed modification |
| SprintStaminaDrainEffect | TSubclassOf<UGameplayEffect> | Effect for stamina drain |
| StaminaRegenEffect | TSubclassOf<UGameplayEffect> | Effect for stamina regeneration |
| StaminaRegenDelayEffect | TSubclassOf<UGameplayEffect> | Effect blocking regen after exhaustion |
| MovementSpeedAttributeTag | FGameplayTag | Tag for movement speed attribute (e.g., "Attribute.Movement.WalkSpeed") |
| StaminaAttributeTag | FGameplayTag | Tag for stamina attribute (e.g., "Attribute.Movement.Stamina") |
Tag Effects
| Property | Type | Description |
|---|---|---|
| WantsToSprintTagEffect | TSubclassOf<UGameplayEffect> | Grants wants to sprint tag |
| SprintingTagEffect | TSubclassOf<UGameplayEffect> | Grants sprinting state tag |
State Tracking (Read-Only)
| Property | Type | Description |
|---|---|---|
| SprintCameraShakeIdentifier | FString | Unique identifier for sprint camera shake |
| bIsLocallyPredicting | bool | Whether component is in local prediction state |
| LocalPredictedSpeed | float | Locally predicted speed value |
| LastLocalPredictionTime | double | Timestamp of last prediction change |
Debug
| Property | Type | Default | Description |
|---|---|---|---|
| bShowDebugInformation | bool | false | Debug information display |
Input Binding
The component provides multiple ways to bind sprint input:
Blueprint Binding
cpp
// Simple binding with auto-discovery
BindSprintInput(SprintInputAction);
// Explicit component binding
BindSprintInputWithComponent(SprintAction, EnhancedInputComponent);Manual Binding
cpp
// Get function names for custom binding
FName StartFunction = GetSprintStartedFunctionName();
FName CompleteFunction = GetSprintCompletedFunctionName();Stamina System
Stamina Flow Diagram
Stamina Access
- GetCurrentStamina() - Returns normalized stamina (0.0 - 1.0)
- GetStaminaFromGAS() - Returns raw stamina value from GAS
- OnStaminaChanged event - Fires when stamina value changes
- OnStaminaFullyRecovered event - Fires when stamina reaches maximum
Local Prediction
Supports client-side prediction for responsive multiplayer:
Prediction API
- IsLocallyPredicting() - Check if in local prediction state
- GetLocalPredictedSpeed() - Get predicted speed value
- GetLastLocalPredictionTime() - Get timestamp of last prediction
Networking
The component handles multiplayer through:
- Server RPCs -
ServerRequestSprint()for authoritative validation - Client Prediction - Immediate local feedback
- GAS Replication - Automatic effect synchronization
- State Reconciliation - Smooth correction of mispredictions