p.MaxFallingCorrectionLeash

p.MaxFallingCorrectionLeash

#Overview

name: p.MaxFallingCorrectionLeash

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

It is referenced in 5 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of p.MaxFallingCorrectionLeash is to control the maximum allowed distance between server and client locations when a character is airborne in Unreal Engine 5. This setting is primarily used in the character movement system to prevent sudden corrections when clients jump from moving bases.

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 used in the runtime environment.

The value of this variable is set through a console variable (CVar) system. It’s defined as a static float variable named MaxFallingCorrectionLeash and is associated with the console variable “p.MaxFallingCorrectionLeash”.

The MaxFallingCorrectionLeash variable interacts with other variables such as ClientAuthorityThreshold and MaxServerClientErrorWhileFalling. These variables work together to determine how much trust is given to the client’s position during character movement, especially when falling or landing.

Developers must be aware that this variable affects network gameplay, particularly in scenarios where characters are jumping or falling. It’s a balance between smooth gameplay experience and preventing cheating. Setting this value too high might allow for exploits, while setting it too low might result in jarring corrections for players.

Best practices when using this variable include:

  1. Testing thoroughly in networked environments to find the right balance.
  2. Considering the types of movement in your game, especially if you have a lot of aerial or platforming gameplay.
  3. Using in conjunction with other related variables like ClientAuthorityThreshold for fine-tuned control.

Regarding the associated variable MaxFallingCorrectionLeash:

The purpose of MaxFallingCorrectionLeash is the same as p.MaxFallingCorrectionLeash, as they share the same value. It’s the C++ variable that directly holds the value set by the console variable.

This variable is used in the UCharacterMovementComponent::ServerMoveHandleClientError function to calculate the maximum allowed error between server and client positions during falling.

The value of this variable is set by the console variable system and can be adjusted at runtime.

It interacts closely with ClientAuthorityThreshold and MaxServerClientErrorWhileFalling to determine the level of trust given to client positions during falling and landing.

Developers should be aware that this variable directly affects the gameplay feel and network behavior of character movement. It’s crucial for maintaining a balance between responsive player control and server authority.

Best practices include monitoring this value during gameplay testing, adjusting it based on the specific needs of your game’s movement system, and considering its impact on both client and server performance.

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

Scope (from outer to inner):

file
namespace    CharacterMovementCVars

Source code excerpt:

	static float MaxFallingCorrectionLeash = 0.f;
	FAutoConsoleVariableRef CVarMaxFallingCorrectionLeash(
		TEXT("p.MaxFallingCorrectionLeash"),
		MaxFallingCorrectionLeash,
		TEXT("When airborne, some distance between the server and client locations may remain to avoid sudden corrections as clients jump from moving bases. This value is the maximum allowed distance."),
		ECVF_Default);

	static float MaxFallingCorrectionLeashBuffer = 10.f;
	FAutoConsoleVariableRef CVarMaxFallingCorrectionLeashBuffer(

#Associated Variable and Callsites

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

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

Scope (from outer to inner):

file
namespace    CharacterMovementCVars

Source code excerpt:

		ECVF_Default);

	static float MaxFallingCorrectionLeash = 0.f;
	FAutoConsoleVariableRef CVarMaxFallingCorrectionLeash(
		TEXT("p.MaxFallingCorrectionLeash"),
		MaxFallingCorrectionLeash,
		TEXT("When airborne, some distance between the server and client locations may remain to avoid sudden corrections as clients jump from moving bases. This value is the maximum allowed distance."),
		ECVF_Default);

	static float MaxFallingCorrectionLeashBuffer = 10.f;
	FAutoConsoleVariableRef CVarMaxFallingCorrectionLeashBuffer(
		TEXT("p.MaxFallingCorrectionLeashBuffer"),

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

Scope (from outer to inner):

file
function     void UCharacterMovementComponent::ServerMoveHandleClientError

Source code excerpt:

	// Potentially trust the client a little when landing
	const float ClientAuthorityThreshold = CharacterMovementCVars::ClientAuthorityThresholdOnBaseChange;
	const float MaxFallingCorrectionLeash = CharacterMovementCVars::MaxFallingCorrectionLeash;
	const bool bDeferServerCorrectionsWhenFalling = ClientAuthorityThreshold > 0.f || MaxFallingCorrectionLeash > 0.f;
	if (bDeferServerCorrectionsWhenFalling)
	{
		// Teleports and other movement modes mean we should just trust the server like we normally would
		if (bTeleportedSinceLastUpdate || (MovementMode != MOVE_Walking && MovementMode != MOVE_Falling))
		{
			MaxServerClientErrorWhileFalling = 0.f;

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

Scope (from outer to inner):

file
function     void UCharacterMovementComponent::ServerMoveHandleClientError

Source code excerpt:

		}

		// MaxFallingCorrectionLeash indicates we'll use a variable correction size based on the error on take-off and the direction of movement.
		// ClientAuthorityThreshold is an static client-trusting correction upon landing.
		// If both are set, use the smaller of the two. If only one is set, use that. If neither are set, we wouldn't even be inside this block.
		float MaxLandingCorrection = 0.f;
		if (ClientAuthorityThreshold > 0.f && MaxFallingCorrectionLeash > 0.f)
		{
			MaxLandingCorrection = FMath::Min(ClientAuthorityThreshold, MaxServerClientErrorWhileFalling);
		}
		else
		{
			MaxLandingCorrection = FMath::Max(ClientAuthorityThreshold, MaxServerClientErrorWhileFalling);

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

Scope (from outer to inner):

file
function     void UCharacterMovementComponent::ServerMoveHandleClientError

Source code excerpt:

			if (ClientForwardFactor < 1.f)
			{
				MaxServerClientErrorWhileFalling = FMath::Min((ServerLoc - ClientLoc).Size() * (1.f - ClientForwardFactor), MaxFallingCorrectionLeash);
				bCanTrustClientOnLanding = true;
			}
			else
			{
				MaxServerClientErrorWhileFalling = 0.f;
				bCanTrustClientOnLanding = false;