p.ClientAuthorityThresholdOnBaseChange

p.ClientAuthorityThresholdOnBaseChange

#Overview

name: p.ClientAuthorityThresholdOnBaseChange

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.ClientAuthorityThresholdOnBaseChange is to manage client-server synchronization in the character movement system, specifically when a pawn moves onto or off of a moving base. This setting is designed to reduce abrupt corrections that can occur in these scenarios by allowing some level of client authority.

This setting variable is primarily used in the Unreal Engine’s character movement system, which is part of the Engine module. It’s specifically utilized in the CharacterMovementComponent, which handles movement for character-based actors in the game.

The value of this variable is set through the Unreal Engine’s console variable system. It’s defined as a static float within the CharacterMovementCVars namespace and is exposed as a console variable using FAutoConsoleVariableRef. This allows the value to be changed at runtime through console commands or configuration files.

The p.ClientAuthorityThresholdOnBaseChange variable interacts closely with another variable named ClientAuthorityThresholdOnBaseChange. They share the same value, with the ‘p.’ prefix version being the console-accessible name.

Developers must be aware that this variable affects the trust given to client-side movement calculations when a pawn changes its base. A non-zero value allows for some client authority, potentially smoothing out gameplay but also opening up possibilities for client-side cheating if not carefully managed.

Best practices when using this variable include:

  1. Start with a low value and gradually increase it while testing to find the right balance between smooth gameplay and server authority.
  2. Monitor for potential exploitation, especially in competitive multiplayer games.
  3. Consider different values for different game modes or player skill levels.
  4. Use in conjunction with other anti-cheat measures for a more robust solution.

Regarding the associated variable ClientAuthorityThresholdOnBaseChange:

This is the internal representation of the console variable. It’s used directly in the game code, particularly in the ServerMoveHandleClientError function of the CharacterMovementComponent.

The purpose of ClientAuthorityThresholdOnBaseChange is the same as p.ClientAuthorityThresholdOnBaseChange - to determine how much to trust the client’s position when changing bases.

It’s used in conjunction with another variable, MaxFallingCorrectionLeash, to decide whether to defer server corrections when the character is falling. This suggests that it’s particularly important for managing smooth transitions when characters move from falling onto moving platforms or vice versa.

Developers should be aware that changes to this variable will directly affect the behavior of the character movement system, particularly in networked games. It’s crucial to test thoroughly with various network conditions to ensure a good balance between responsiveness and server authority.

Best practices for ClientAuthorityThresholdOnBaseChange include:

  1. Always access it through the CharacterMovementCVars namespace to ensure you’re using the current value.
  2. Consider exposing it as a configurable option for different game modes or difficulty levels.
  3. Use it in conjunction with other movement-related variables for a cohesive movement system.
  4. Regularly review and adjust its value based on player feedback and gameplay analysis.

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

Scope (from outer to inner):

file
namespace    CharacterMovementCVars

Source code excerpt:

	static float ClientAuthorityThresholdOnBaseChange = 0.f;
	FAutoConsoleVariableRef CVarClientAuthorityThresholdOnBaseChange(
		TEXT("p.ClientAuthorityThresholdOnBaseChange"),
		ClientAuthorityThresholdOnBaseChange,
		TEXT("When a pawn moves onto or off of a moving base, this can cause an abrupt correction. In these cases, trust the client up to this distance away from the server component location."),
		ECVF_Default);

	static float MaxFallingCorrectionLeash = 0.f;
	FAutoConsoleVariableRef CVarMaxFallingCorrectionLeash(

#Associated Variable and Callsites

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

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

Scope (from outer to inner):

file
namespace    CharacterMovementCVars

Source code excerpt:

		UseTargetVelocityOnImpact, TEXT("When disabled, we recalculate velocity after impact by comparing our position before we moved to our position after we moved. This doesn't work correctly when colliding with physics objects, so setting this to 1 fixes this one the hit object is moving."));

	static float ClientAuthorityThresholdOnBaseChange = 0.f;
	FAutoConsoleVariableRef CVarClientAuthorityThresholdOnBaseChange(
		TEXT("p.ClientAuthorityThresholdOnBaseChange"),
		ClientAuthorityThresholdOnBaseChange,
		TEXT("When a pawn moves onto or off of a moving base, this can cause an abrupt correction. In these cases, trust the client up to this distance away from the server component location."),
		ECVF_Default);

	static float MaxFallingCorrectionLeash = 0.f;
	FAutoConsoleVariableRef CVarMaxFallingCorrectionLeash(
		TEXT("p.MaxFallingCorrectionLeash"),

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

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))