p.MaxFallingCorrectionLeashBuffer

p.MaxFallingCorrectionLeashBuffer

#Overview

name: p.MaxFallingCorrectionLeashBuffer

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

It is referenced in 3 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of p.MaxFallingCorrectionLeashBuffer is to fine-tune the character movement correction system when characters are falling, specifically to avoid constant corrections between the server and client positions.

This setting variable is primarily used in the Unreal Engine’s character movement system, specifically within the CharacterMovementComponent. It’s part of the Engine module and is crucial for maintaining smooth and accurate character movement in networked gameplay scenarios.

The value of this variable is set using an FAutoConsoleVariableRef, which allows it to be adjusted at runtime through console commands. It’s initialized with a default value of 10.0f.

The p.MaxFallingCorrectionLeashBuffer interacts closely with the MaxServerClientErrorWhileFalling variable. Together, they determine the threshold at which the server will correct the client’s position during falling.

Developers should be aware that this variable affects the tolerance for discrepancies between server and client positions during falling. A larger value will allow for more divergence before correction, potentially reducing network traffic but possibly leading to more noticeable corrections when they do occur.

Best practices when using this variable include:

  1. Carefully balancing it with other movement-related variables to achieve smooth gameplay.
  2. Testing thoroughly in networked environments to ensure it provides the desired behavior.
  3. Considering adjusting it based on the specific needs of your game’s movement mechanics.

Regarding the associated variable MaxFallingCorrectionLeashBuffer:

This is the actual C++ variable that stores the value set by p.MaxFallingCorrectionLeashBuffer. It’s used directly in the character movement code to calculate position corrections.

The purpose of MaxFallingCorrectionLeashBuffer is the same as p.MaxFallingCorrectionLeashBuffer - it’s the internal representation of the console variable.

It’s used within the ServerMoveHandleClientError function of the CharacterMovementComponent to adjust the server’s perception of the client’s position during falling, effectively giving the client more leeway before a correction is applied.

The value of MaxFallingCorrectionLeashBuffer is set automatically when p.MaxFallingCorrectionLeashBuffer is changed, thanks to the FAutoConsoleVariableRef system.

Developers should be aware that modifying MaxFallingCorrectionLeashBuffer directly in code won’t persist, as it will be overwritten by the console variable system. Always use the p.MaxFallingCorrectionLeashBuffer console variable to change this value.

Best practices for MaxFallingCorrectionLeashBuffer are the same as for p.MaxFallingCorrectionLeashBuffer, with the additional note that developers should generally interact with the console variable (p.MaxFallingCorrectionLeashBuffer) rather than the C++ variable directly.

#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:285

Scope (from outer to inner):

file
namespace    CharacterMovementCVars

Source code excerpt:

	static float MaxFallingCorrectionLeashBuffer = 10.f;
	FAutoConsoleVariableRef CVarMaxFallingCorrectionLeashBuffer(
		TEXT("p.MaxFallingCorrectionLeashBuffer"),
		MaxFallingCorrectionLeashBuffer,
		TEXT("To avoid constant corrections, when an airborne server and client are further than p.MaxFallingCorrectionLeash cm apart, they'll be pulled in to that distance minus this value."),
		ECVF_Default);

	static bool bAddFormerBaseVelocityToRootMotionOverrideWhenFalling = true;
	FAutoConsoleVariableRef CVarAddFormerBaseVelocityToRootMotionOverrideWhenFalling(

#Associated Variable and Callsites

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

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

Scope (from outer to inner):

file
namespace    CharacterMovementCVars

Source code excerpt:

		ECVF_Default);

	static float MaxFallingCorrectionLeashBuffer = 10.f;
	FAutoConsoleVariableRef CVarMaxFallingCorrectionLeashBuffer(
		TEXT("p.MaxFallingCorrectionLeashBuffer"),
		MaxFallingCorrectionLeashBuffer,
		TEXT("To avoid constant corrections, when an airborne server and client are further than p.MaxFallingCorrectionLeash cm apart, they'll be pulled in to that distance minus this value."),
		ECVF_Default);

	static bool bAddFormerBaseVelocityToRootMotionOverrideWhenFalling = true;
	FAutoConsoleVariableRef CVarAddFormerBaseVelocityToRootMotionOverrideWhenFalling(
		TEXT("p.AddFormerBaseVelocityToRootMotionOverrideWhenFalling"),

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

Scope (from outer to inner):

file
function     void UCharacterMovementComponent::ServerMoveHandleClientError

Source code excerpt:

				// This is not actually changing the server position, but changing it as far as corrections are concerned.
				// This means we're just holding the client on a longer leash while we're falling.
				ServerLoc = ServerLoc - LocDiff.GetSafeNormal() * FMath::Clamp(MaxServerClientErrorWhileFalling - CharacterMovementCVars::MaxFallingCorrectionLeashBuffer, 0.f, MaxServerClientErrorWhileFalling);
			}
		}
	}

	// Compute the client error from the server's position
	// If client has accumulated a noticeable positional error, correct them.