Skip to content

MotionSprintingComponent

MotionSprintingComponent handles sprint intent, sprint speed, optional stamina, local prediction, and GAS-backed sprint state.

Requirements

  • Character with standard UCharacterMovementComponent
  • A resolvable UAbilitySystemComponent, commonly exposed by a PlayerState that implements IAbilitySystemInterface
  • Gameplay Ability System initialized
  • Enhanced Input configured
  • Sprint GameplayEffects such as speed, stamina drain, stamina regen, regen delay, wants-to-sprint, and sprinting state
  • GameplayTags for sprint intent, active sprinting, walk speed, and optional stamina

For setup and input binding steps, see How to add Motion to a character.

Behavior

The component turns sprint input into authoritative movement state. It validates whether sprint can start, applies speed and tag effects, starts sprint camera feedback, optionally drains stamina, and reconciles local prediction with server state.

When stamina is enabled, sprinting can pause, recover, or force input release after depletion. Hysteresis thresholds keep sprint start and sprint stop behavior stable.

API

Sprint state

  • SetWantsToSprint(bool bWantsToSprint) -> void: sets sprint intent.
  • GetWantsToSprint() -> bool: returns sprint intent.
  • IsCurrentlySprinting() -> bool: returns active sprint state.
  • CanStartSprinting() -> bool: checks whether sprint can begin.
  • UpdateSprintingState(float DeltaTime) -> void: updates sprint state and effects.

Stamina

  • GetStaminaFromGAS() -> float: reads raw stamina from GAS.
  • GetCurrentStamina() -> float: returns normalized stamina.
  • UpdateStamina(float DeltaTime) -> void: updates stamina drain or recovery.
  • UpdateStaminaWithGameplayEffects(float DeltaTime) -> void: manages stamina GameplayEffects.
  • OnStaminaAttributeChanged(FOnAttributeChangeData&) -> void: reacts to stamina attribute changes.
  • OnStaminaDepleted(float CurrentValue) -> void: handles exhaustion.

Speed and movement

  • ApplySprintSpeedModification() -> void: applies sprint speed effect.
  • RemoveSprintSpeedModification() -> void: removes sprint speed effect.
  • GetCurrentMovementSpeed() -> float: returns current speed.
  • IsActuallyMoving() -> bool: checks whether velocity is high enough to count as movement.

Camera and input

  • StartSprintCameraEffects() -> void: starts sprint camera feedback.
  • StopSprintCameraEffects() -> void: stops sprint camera feedback.
  • OnInputStarted(FInputActionValue&) -> void: handles sprint input press.
  • OnInputCompleted(FInputActionValue&) -> void: handles sprint input release.
  • HandleSprintInputStateChange(bool bPressed) -> void: processes sprint input state.
  • BindSprintInput(UInputAction*) -> bool: binds sprint input through auto-discovery.
  • BindSprintInputWithComponent(UInputAction*, UEnhancedInputComponent*) -> bool: binds sprint input through an explicit input component.

Prediction and networking

  • IsLocallyPredicting() -> bool: returns whether the component is in local prediction.
  • GetLocalPredictedSpeed() -> float: returns predicted local speed.
  • GetLastLocalPredictionTime() -> double: returns the last prediction timestamp.
  • ServerRequestSprint(bool bWantsToSprint) -> void: server RPC for authoritative sprint validation.

Configuration

Configuration lives on the assigned MotionSprintProfile. The current Motion default is /MotionCore/Motion/Profiles/v2_0_0/DA_MotionSprintProfile_Default_v2_0_0.

Sprint settings

  • SprintWalkSpeedModifier: walk speed value added while sprinting. Default: 300.0.
  • bRequiresContinuousInput: whether sprint requires held input. Default: true.
  • BaseWalkSpeed: fallback base speed used for sprint prediction when no MotionWalkComponent is present. With a Walk Component, sprinting uses the assigned walk profile's BaseWalkSpeed.

Stamina settings

  • bUseStaminaSystem: whether sprinting is limited by stamina. Default: true.
  • MinStaminaToSprint: raw stamina required to start sprinting. Default: 1.5.
  • MinStaminaToStopSprinting: minimum stamina to continue sprinting. Default: 0.25.
  • MinSprintVelocity: minimum velocity for sprint camera shake. Default: 50.0.
  • RegenDelayDuration: time to block regeneration after exhaustion. Default: 2.0.
  • bForceReleaseOnStaminaDepletion: whether depletion clears sprint intent. Default: true.

Effects and tags

  • SprintCameraShake: camera curve used while sprinting.
  • bApplyCameraShake: whether sprint camera shake is applied.
  • SprintSpeedEffect: speed modifier effect.
  • SprintStaminaDrainEffect: stamina drain effect.
  • StaminaRegenEffect: stamina regeneration effect.
  • StaminaRegenDelayEffect: post-exhaustion regeneration delay.
  • WantsToSprintTagEffect: grants wants-to-sprint tag.
  • SprintingTagEffect: grants sprinting state tag.

The component's editable setup surface is the Profile reference. Runtime prediction, stamina handles, replicated state, and diagnostics remain component-owned.

Read-Only State

  • SprintCameraShakeIdentifier: identifier for sprint camera shake.
  • bIsLocallyPredicting: whether local prediction is active.
  • LocalPredictedSpeed: predicted local speed value.
  • LastLocalPredictionTime: timestamp of last prediction.

Blueprint Events

  • OnSprintStateChanged(bool bIsSprinting): fires when sprint state changes.
  • OnSprintStaminaDepleted(): fires when stamina is depleted.
  • OnStaminaFullyRecovered(): fires when stamina reaches maximum.
  • OnStaminaChanged(float NewStamina, float MaxStamina): fires when stamina changes.

Networking

Sprinting uses server RPCs for validation, client prediction for immediate local response, GAS replication for effects, and reconciliation when prediction differs from server authority.

Motion - Advanced First Person Character Controller