p.DeferCharacterMeshMovementForAllCorrections
p.DeferCharacterMeshMovementForAllCorrections
#Overview
name: p.DeferCharacterMeshMovementForAllCorrections
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Optimization - When enabled, defers CharacterMesh move propagation for all corrections until the end of larger scoped moves. Requires
bDeferCharacterMeshMovement=true'.`
It is referenced in 3
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of p.DeferCharacterMeshMovementForAllCorrections
is to optimize character mesh movement in Unreal Engine 5 by deferring mesh movement propagation for all corrections until the end of larger scoped moves.
This setting variable is primarily used in the Character Movement Component, which is part of the Engine module in Unreal Engine 5. It specifically affects the character movement and mesh update system.
The value of this variable is set as a console variable using FAutoConsoleVariableRef
. It is initialized to true
by default, but can be changed at runtime through the console or configuration files.
This variable interacts closely with another boolean variable bDeferCharacterMeshMovementForAllCorrections
. They share the same value, and the console variable essentially controls the state of this boolean.
Developers must be aware of the following when using this variable:
- It requires
bDeferCharacterMeshMovement
to be set totrue
for it to have any effect. - This is an optimization feature, so it may impact the visual update frequency of character meshes.
- It affects all corrections, which could potentially lead to noticeable delays in mesh updates if not used carefully.
Best practices when using this variable include:
- Thoroughly test the game with this optimization both enabled and disabled to ensure it doesn’t introduce visual artifacts or gameplay issues.
- Monitor performance metrics to confirm that it’s providing the expected optimization benefits.
- Consider disabling this in debug builds or providing an easy way to toggle it for testing purposes.
Regarding the associated variable bDeferCharacterMeshMovementForAllCorrections
:
This is a static boolean variable used internally by the Character Movement Component. Its purpose is to store the state set by the console variable p.DeferCharacterMeshMovementForAllCorrections
.
It’s used in the UCharacterMovementComponent::ClientUpdatePositionAfterServerUpdate
function to determine whether to create a scoped mesh movement update. This affects how and when character mesh updates are propagated during network corrections.
Developers should be aware that changing the console variable p.DeferCharacterMeshMovementForAllCorrections
will directly affect this boolean, and thus the behavior of the character movement component during network updates.
Best practices for this associated variable include:
- Treat it as read-only in most cases, modifying it through the console variable instead.
- Be cautious about directly accessing or modifying this variable in custom code, as it could lead to inconsistent behavior if not synchronized with the console variable.
#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:327
Scope (from outer to inner):
file
namespace CharacterMovementCVars
Source code excerpt:
static bool bDeferCharacterMeshMovementForAllCorrections = true;
FAutoConsoleVariableRef CVarDeferCharacterMeshMovementForAllCorrections(
TEXT("p.DeferCharacterMeshMovementForAllCorrections"),
bDeferCharacterMeshMovementForAllCorrections,
TEXT("Optimization - When enabled, defers CharacterMesh move propagation for all corrections until the end of larger scoped moves. Requires `bDeferCharacterMeshMovement=true'."),
ECVF_Default);
#if !UE_BUILD_SHIPPING
#Associated Variable and Callsites
This variable is associated with another variable named bDeferCharacterMeshMovementForAllCorrections
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/Components/CharacterMovementComponent.cpp:325
Scope (from outer to inner):
file
namespace CharacterMovementCVars
Source code excerpt:
ECVF_Default);
static bool bDeferCharacterMeshMovementForAllCorrections = true;
FAutoConsoleVariableRef CVarDeferCharacterMeshMovementForAllCorrections(
TEXT("p.DeferCharacterMeshMovementForAllCorrections"),
bDeferCharacterMeshMovementForAllCorrections,
TEXT("Optimization - When enabled, defers CharacterMesh move propagation for all corrections until the end of larger scoped moves. Requires `bDeferCharacterMeshMovement=true'."),
ECVF_Default);
#if !UE_BUILD_SHIPPING
int32 NetShowCorrections = 0;
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/Components/CharacterMovementComponent.cpp:8283
Scope (from outer to inner):
file
function bool UCharacterMovementComponent::ClientUpdatePositionAfterServerUpdate
Source code excerpt:
// Defer all mesh child updates until all movement completes.
FScopedMeshMovementUpdate ScopedMeshUpdate(CharacterOwner->GetMesh(), CharacterMovementCVars::bDeferCharacterMeshMovementForAllCorrections);
// Replay moves that have not yet been acked.
UE_LOG(LogNetPlayerMovement, Verbose, TEXT("ClientUpdatePositionAfterServerUpdate Replaying %d Moves, starting at Timestamp %f"), ClientData->SavedMoves.Num(), ClientData->SavedMoves[0]->TimeStamp);
for (int32 i=0; i<ClientData->SavedMoves.Num(); i++)
{
FSavedMove_Character* const CurrentMove = ClientData->SavedMoves[i].Get();