Skip to content

MotionSprintingComponent

MotionSprintingComponent handles sprint intent, sprint speed, optional stamina, client-predicted intent tags, 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, and optional stamina state

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

Behavior

The component turns sprint input into server-owned movement state. It validates whether sprint can start, applies speed and tag effects, and optionally drains stamina. On the locally controlled sprint transition, it starts camera feedback only when speed is already at least MinSprintVelocity. An owning client predicts the wants-to-sprint tag locally and sends the request to the server.

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

Public 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.

Stamina

  • GetStaminaFromGAS() -> float: reads raw Stamina from GAS, or returns the current 5.0 fallback when the stamina system or attribute is unavailable.
  • GetCurrentStamina() -> float: returns Stamina / MaxStamina when both attributes are available and MaxStamina is positive; otherwise returns 1.0.

Speed and movement

  • GetCurrentMovementSpeed() -> float: returns current speed.
  • IsActuallyMoving() -> bool: checks whether velocity is high enough to count as movement.

Camera and input

  • HandleSprintInputStateChange(bool bPressed) -> void: processes sprint input state.

Prediction and networking

  • IsLocallyPredicting() -> bool: returns the inherited prediction flag. Current sprint code sets it after authoritative sprint-speed effect application or removal on a locally controlled authority instance.
  • GetLocalPredictedSpeed() -> float: returns the corresponding target speed recorded by that authoritative path.

Protected/Internal Behavior

The component owns sprint state updates, stamina effect management, speed-effect application, camera feedback, and stamina attribute callbacks internally. These hooks are protected implementation details, not public Blueprint API:

  • UpdateSprintingState(float DeltaTime) -> void
  • UpdateStamina(float DeltaTime) -> void
  • UpdateStaminaWithGameplayEffects(float DeltaTime) -> void
  • OnStaminaAttributeChanged(const FOnAttributeChangeData& Data) -> void
  • OnStaminaDepleted(float CurrentStaminaValue) -> void
  • ApplySprintSpeedModification() -> void
  • RemoveSprintSpeedModification() -> void
  • StartSprintCameraEffects() -> void
  • StopSprintCameraEffects() -> void
  • ServerRequestSprint(bool bWantsToSprint) -> void: protected server RPC for 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 target calculations when no MotionWalkComponent is present. Default: 600.0. With a Walk Component, sprinting uses that component's profile-applied 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 main setting you edit is the Profile reference. Runtime prediction, stamina handles, replicated state, and diagnostics stay on the component.

Runtime State

These values are protected component state; use the public prediction getters where available.

  • SprintCameraShakeIdentifier: identifier for sprint camera shake.
  • bIsLocallyPredicting: inherited flag set after authoritative speed-effect application or removal on a locally controlled authority instance. Current sprint code does not clear it.
  • LocalPredictedSpeed: last sprint or base-speed target recorded by that path.

Blueprint Events

  • OnSprintStateChangedDelegate(bool bIsSprinting): fires when sprint state changes.
  • OnSprintStaminaDepletedDelegate(): fires when stamina is depleted.
  • OnStaminaFullyRecoveredDelegate(): fires when stamina reaches maximum.
  • OnStaminaChangedDelegate(float NewStamina, float MaxStamina): fires when stamina changes.

Networking

The owning client immediately adds or removes a loose wants-to-sprint tag and sends ServerRequestSprint. The server rate-limits requests, rejects sprint starts with insufficient stamina, and owns sprint tag, speed, drain, regeneration, and regeneration-delay GameplayEffects. GAS replication carries authoritative tags and attributes; camera feedback remains local to the owning view.

Motion - Advanced First Person Character Controller