p.DeferCharacterMeshMovement
p.DeferCharacterMeshMovement
#Overview
name: p.DeferCharacterMeshMovement
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Optimization - When enabled, defers CharacterMesh move propagation until the end of larger scoped moves. The mesh will still move, but all attached components will wait until all mesh movement is done within the scope.
It is referenced in 3
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of p.DeferCharacterMeshMovement is to provide an optimization for character mesh movement in Unreal Engine 5. It is used to control the timing of character mesh movement propagation, specifically for the character movement system.
This setting variable is primarily used in the Engine module, specifically within the CharacterMovementComponent. It affects how the engine handles the movement of character meshes and their attached components.
The value of this variable is set through the Unreal Engine console variable system. It’s defined as a boolean value, initialized to false, which means the optimization is disabled by default.
The associated variable bDeferCharacterMeshMovement directly interacts with p.DeferCharacterMeshMovement. They share the same value, with bDeferCharacterMeshMovement being the C++ variable that the engine code checks to determine whether to apply this optimization.
Developers must be aware that when this variable is enabled, it changes the behavior of character mesh movement. Specifically, it defers the propagation of mesh movement until the end of larger scoped moves. While the mesh itself will still move, all attached components will wait until all mesh movement within the scope is completed before updating their positions.
Best practices when using this variable include:
- Testing thoroughly to ensure that deferring mesh movement doesn’t cause visual artifacts or gameplay issues in your specific use case.
- Consider enabling this for performance optimization, especially in scenarios with many characters or complex character setups.
- Be cautious when using this in conjunction with systems that rely on immediate updates of attached components, as the deferred updates might cause unexpected behavior.
Regarding the associated variable bDeferCharacterMeshMovement:
This is the actual C++ boolean variable that the engine code checks to determine whether to apply the mesh movement deferral optimization. It’s initialized with the same value as p.DeferCharacterMeshMovement and is used in the implementation of the FScopedMeshMovementUpdate class.
The FScopedMeshMovementUpdate class is used to create a scope for mesh movement updates. When bDeferCharacterMeshMovement is true, it creates a deferred update scope for the given mesh, which is likely used to batch movement updates for better performance.
Developers should be aware that changing p.DeferCharacterMeshMovement at runtime will affect bDeferCharacterMeshMovement, potentially changing the behavior of character movement mid-game. This could be useful for performance tweaking but should be used cautiously to avoid introducing inconsistencies in gameplay.
#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:320
Scope (from outer to inner):
file
namespace CharacterMovementCVars
Source code excerpt:
static bool bDeferCharacterMeshMovement = false;
FAutoConsoleVariableRef CVarDeferCharacterMeshMovement(
TEXT("p.DeferCharacterMeshMovement"),
bDeferCharacterMeshMovement,
TEXT("Optimization - When enabled, defers CharacterMesh move propagation until the end of larger scoped moves. The mesh will still move, but all attached components will wait until all mesh movement is done within the scope."),
ECVF_Default);
static bool bDeferCharacterMeshMovementForAllCorrections = true;
FAutoConsoleVariableRef CVarDeferCharacterMeshMovementForAllCorrections(
#Associated Variable and Callsites
This variable is associated with another variable named bDeferCharacterMeshMovement
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/Components/CharacterMovementComponent.cpp:318
Scope (from outer to inner):
file
namespace CharacterMovementCVars
Source code excerpt:
ECVF_Default);
static bool bDeferCharacterMeshMovement = false;
FAutoConsoleVariableRef CVarDeferCharacterMeshMovement(
TEXT("p.DeferCharacterMeshMovement"),
bDeferCharacterMeshMovement,
TEXT("Optimization - When enabled, defers CharacterMesh move propagation until the end of larger scoped moves. The mesh will still move, but all attached components will wait until all mesh movement is done within the scope."),
ECVF_Default);
static bool bDeferCharacterMeshMovementForAllCorrections = true;
FAutoConsoleVariableRef CVarDeferCharacterMeshMovementForAllCorrections(
TEXT("p.DeferCharacterMeshMovementForAllCorrections"),
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/Components/CharacterMovementComponent.cpp:476
Scope (from outer to inner):
file
function FScopedMeshMovementUpdate
Source code excerpt:
{
FScopedMeshMovementUpdate(USkeletalMeshComponent* Mesh, bool bEnabled = true)
: ScopedMoveUpdate(bEnabled && CharacterMovementCVars::bDeferCharacterMeshMovement ? Mesh : nullptr, EScopedUpdate::DeferredUpdates)
{
}
private:
FScopedMovementUpdate ScopedMoveUpdate;
};