RealDocs

UCharacterMovementComponent::GetMaxSpeed

function Engine Since 4.0
#include "GameFramework/CharacterMovementComponent.h"
Access: public Specifiers: virtualconstoverride

Description

Returns the maximum speed allowed for the current MovementMode — MaxWalkSpeedCrouched or MaxWalkSpeed while walking, MaxSwimSpeed while swimming, MaxFlySpeed while flying, or MaxCustomMovementSpeed in MOVE_Custom.

Caveats & Gotchas

  • Returns 0 for MOVE_None, and MaxWalkSpeed (not a separate falling cap) while MOVE_Falling — horizontal falling speed is bounded by the walking speed, not a dedicated falling max.
  • This is the value CalcVelocity() clamps against every tick, so overriding it is the standard way to implement sprinting, slow zones, or other speed modifiers without touching the rest of the movement code.

Signature

virtual float GetMaxSpeed() const override

Return Type

float

Example

Sprint speed override C++
float UMyCharacterMovementComponent::GetMaxSpeed() const
{
    if (bIsSprinting && IsMovingOnGround())
    {
        return Super::GetMaxSpeed() * SprintSpeedMultiplier;
    }
    return Super::GetMaxSpeed();
}

Version History

Introduced in: 4.0

Version Status Notes
5.6 stable

Feedback

Was this helpful?

Suggest an edit

Select a field above to begin editing.