BP_SprintingComponent

This page describes the Sprinting Component that ships with Motion. The Sprinting Component provides an alternative movement mode for players. When holding (or pressing) the Sprint Key, the player accelerates towards a sprint bonus speed that can be configured in this component.

The component also detects if the player is moving backwards or sideways, either aborting the sprint or applying a speed penalty for moving sideways.

While the player sprints, a camera shake is applied.

Dependencies

  • requires BP_WalkingComponent.

  • requires BP_CrouchingComponent.

Methods

Manipulators

Name
Description

CalculateCurrentPenalty

Gets the current penalty and applies it, unless the newly calculated penalty is near to zero

LerpTowardsSprintingSpeed

Applies the current speed bonus

ResetPenalty

Resets penalty related variables

ResetSprint

Resets sprint state and speed

UpdateDeltaSeconds

Updates progress on sprint shake camera curve, timer for holding the key down & penalty timer if penalized

UpdateMovementDirection

Determines which direction the player is moving towards to by parsing their normalized direction

UpdateTargetCameraRotation

Gets the current position of the camera shake curve and updates the target rotation

ValidateActiveDeltaSeconds

Checks if the sprint shake curve progress is at its peak and resets it then to ensure looped camera movement

ValidateMovement

Updates status of player being able to sprint and applies / resets penalty according to movement changes

Event Handler

Name
Description

HandleOnEventBeginPlay

Called when "Event Begin Play" gets called. Sets up events and gets component references.

HandleOnEventTick

Core logic handling. See detailed comments.

HandleOnSprintPressed

When pressing the sprint key, reset timers & toggle sprint key state

HandleOnSprintReleased

When releasing the sprint key, reset sprint timers, state & values

HandleOnVelocityStop

Called when player stops moving. Resets sprinting.

Debug

Name
Description

PrintDebugInformation

Prints useful information on the screen. Helpful for debugging.


Variables

Configuration

Name
Description

SprintCameraLocationOffsetAnimationTime

The amount of time it should take to animate towards the SprintCameraLocationOffset

SprintCameraLocationOffset

The offset that should be lerped towards to when the user starts sprinting.

SprintAccelerationCurve

The curve float used to accelerate the player into sprinting to SprintSpeed

SprintShakeCurve

The curve vector used to move the camera when sprinting

bIsInputToggle

If true, the input key is used as toggle. This is especially useful for use on gamepads where it is more tiring to hold down a button.

bShowDebugInformation

If ticked, various useful variables will be printed on the screen to help with debugging

bIsEnabled

If unticked, the component will only print debug data and not update any other values.

Constants

Name
Description

CurveType

Type Identifier for the curves created by this component.

Default

Name
Description

WalkingComponent

Reference to the crouch component

CrouchComponent

Reference to the crouch component

States

Name
Description

bHasBeenPenalized

If true, the player has already been penalized for a penalized movement action.

bIsPenalized

If true, the sprint speed is currently penalized (e.g. due to penalized movement)

bCanSprint

If true, all conditions are met that would allow the player to start sprinting

bIsSprinting

If true, the player is sprinting

bIsHoldingSprintKey

If true, the player is holding down the sprint key

Component Data

Name
Description

CurrentEnumCurveResult

The current position of the curve

CurrentMovementDirection

The current direction the player is moving towards to

CurrentTargetRotation

The current requested camera offset for this compoenent

Last updated