p.AddFormerBaseVelocityToRootMotionOverrideWhenFalling

p.AddFormerBaseVelocityToRootMotionOverrideWhenFalling

#Overview

name: p.AddFormerBaseVelocityToRootMotionOverrideWhenFalling

This variable is created as a Console Variable (cvar).

It is referenced in 4 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of p.AddFormerBaseVelocityToRootMotionOverrideWhenFalling is to prevent sudden velocity changes when a root motion source moves a pawn from a moving base to free fall. This setting variable is primarily used in the character movement system of Unreal Engine 5.

This setting variable is used in the CharacterMovementComponent, which is part of the Engine module. It specifically affects the behavior of root motion and velocity calculations when a character transitions from a moving base to falling.

The value of this variable is set to true by default in the CharacterMovementCVars namespace. It can be modified at runtime through the Unreal Engine console system, as it’s defined as an FAutoConsoleVariableRef.

The associated variable bAddFormerBaseVelocityToRootMotionOverrideWhenFalling directly interacts with this console variable. They share the same value and purpose.

Developers must be aware that this variable affects the FormerBaseVelocityDecayHalfLife property on CharacterMovementComponent. When enabled, it allows for a smoother transition of velocity when a character leaves a moving platform and enters a falling state.

Best practices when using this variable include:

  1. Consider the impact on gameplay and character movement feel when modifying this setting.
  2. Test thoroughly in scenarios where characters frequently transition between moving platforms and falling states.
  3. Use in conjunction with the FormerBaseVelocityDecayHalfLife property for fine-tuning the decay of the former base velocity.

Regarding the associated variable bAddFormerBaseVelocityToRootMotionOverrideWhenFalling:

#References in C++ code

#Callsites

This variable is referenced in the following C++ source code:

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/Components/CharacterMovementComponent.cpp:292

Scope (from outer to inner):

file
namespace    CharacterMovementCVars

Source code excerpt:

	static bool bAddFormerBaseVelocityToRootMotionOverrideWhenFalling = true;
	FAutoConsoleVariableRef CVarAddFormerBaseVelocityToRootMotionOverrideWhenFalling(
		TEXT("p.AddFormerBaseVelocityToRootMotionOverrideWhenFalling"),
		bAddFormerBaseVelocityToRootMotionOverrideWhenFalling,
		TEXT("To avoid sudden velocity changes when a root motion source moves the pawn from a moving base to free fall, this CVar will enable the FormerBaseVelocityDecayHalfLife property on CharacterMovementComponent."),
		ECVF_Default);

	static bool bGeometryCollectionImpulseWorkAround = true;
	FAutoConsoleVariableRef CVarGeometryCollectionImpulseWorkAround(

#Associated Variable and Callsites

This variable is associated with another variable named bAddFormerBaseVelocityToRootMotionOverrideWhenFalling. They share the same value. See the following C++ source code.

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/Components/CharacterMovementComponent.cpp:290

Scope (from outer to inner):

file
namespace    CharacterMovementCVars

Source code excerpt:

		ECVF_Default);

	static bool bAddFormerBaseVelocityToRootMotionOverrideWhenFalling = true;
	FAutoConsoleVariableRef CVarAddFormerBaseVelocityToRootMotionOverrideWhenFalling(
		TEXT("p.AddFormerBaseVelocityToRootMotionOverrideWhenFalling"),
		bAddFormerBaseVelocityToRootMotionOverrideWhenFalling,
		TEXT("To avoid sudden velocity changes when a root motion source moves the pawn from a moving base to free fall, this CVar will enable the FormerBaseVelocityDecayHalfLife property on CharacterMovementComponent."),
		ECVF_Default);

	static bool bGeometryCollectionImpulseWorkAround = true;
	FAutoConsoleVariableRef CVarGeometryCollectionImpulseWorkAround(
		TEXT("p.CVarGeometryCollectionImpulseWorkAround"),

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/Components/CharacterMovementComponent.cpp:2541

Scope (from outer to inner):

file
function     void UCharacterMovementComponent::ApplyImpartedMovementBaseVelocity

Source code excerpt:

		CurrentRootMotion.LastPreAdditiveVelocity += DecayingFormerBaseVelocity;
	}
	if (!CharacterMovementCVars::bAddFormerBaseVelocityToRootMotionOverrideWhenFalling || FormerBaseVelocityDecayHalfLife == 0.f)
	{
		DecayingFormerBaseVelocity = FVector::ZeroVector;
	}
}

void UCharacterMovementComponent::DisableMovement()

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/Components/CharacterMovementComponent.cpp:4355

Scope (from outer to inner):

file
function     void UCharacterMovementComponent::DecayFormerBaseVelocity

Source code excerpt:

void UCharacterMovementComponent::DecayFormerBaseVelocity(float deltaTime)
{
	if (!CharacterMovementCVars::bAddFormerBaseVelocityToRootMotionOverrideWhenFalling || FormerBaseVelocityDecayHalfLife == 0.f)
	{
		DecayingFormerBaseVelocity = FVector::ZeroVector;
	}
	else if (FormerBaseVelocityDecayHalfLife > 0.f)
	{
		DecayingFormerBaseVelocity *= FMath::Exp2(-deltaTime * 1.f / FormerBaseVelocityDecayHalfLife);