ClientAuthorativePosition

ClientAuthorativePosition

#Overview

name: ClientAuthorativePosition

The value of this variable can be defined or overridden in .ini config files. 1 .ini config file referencing this setting variable.

It is referenced in 6 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of ClientAuthorativePosition is to allow clients to have authoritative control over their final position in networked gameplay. This setting is primarily used in the character movement system of Unreal Engine 5.

ClientAuthorativePosition is primarily relied upon by the Character Movement Component and the Game Network Manager subsystems within Unreal Engine.

The value of this variable is typically set in the Game Network Manager class, which is a global configuration. It is initialized to false by default in the AGameNetworkManager constructor.

This variable interacts with several other settings, including:

Developers must be aware that enabling ClientAuthorativePosition can have significant implications for game security and fairness. When enabled, the server will trust the client’s reported position, which can potentially be exploited by cheaters.

Best practices when using this variable include:

  1. Only enable it if absolutely necessary for your game’s design.
  2. Implement additional anti-cheat measures if this setting is enabled.
  3. Consider using it in conjunction with error checking mechanisms, such as MAXPOSITIONERRORSQUARED, to limit the potential for abuse.
  4. Be aware of its interaction with movement time discrepancy detection and resolution features.
  5. Test thoroughly in networked environments to ensure it doesn’t introduce unexpected behavior or vulnerabilities.

When this setting is false (default), the server remains the authority on player positions, which is generally considered more secure for most multiplayer games.

#Setting Variables

#References In INI files

Location: <Workspace>/Engine/Config/BaseGame.ini:38, section: [/Script/Engine.GameNetworkManager]

#References in C++ code

#Callsites

This variable is referenced in the following C++ source code:

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Classes/GameFramework/CharacterMovementComponent.h:957

Scope: file

Source code excerpt:

	 * This can be useful for short bursts of movement that are difficult to sync over the network.
	 * Note that if bIgnoreClientMovementErrorChecksAndCorrection is used, this means the server will not detect an error.
	 * Also see GameNetworkManager->ClientAuthorativePosition which permanently enables this behavior.
	 * @see bIgnoreClientMovementErrorChecksAndCorrection, ServerShouldUseAuthoritativePosition()
	 */
	UPROPERTY(Transient, Category="Character Movement", EditAnywhere, BlueprintReadWrite)
	uint8 bServerAcceptClientAuthoritativePosition : 1;

	/**
	 * If true, event NotifyJumpApex() to CharacterOwner's controller when at apex of jump. Is cleared when event is triggered.
	 * By default this is off, and if you want the event to fire you typically set it to true when movement mode changes to "Falling" from another mode (see OnMovementModeChanged).
	 */
	UPROPERTY(Category="Character Movement: Jumping / Falling", VisibleAnywhere, BlueprintReadWrite)
	uint8 bNotifyApex:1;

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Classes/GameFramework/GameNetworkManager.h:186

Scope (from outer to inner):

file
class        class AGameNetworkManager : public AInfo

Source code excerpt:

	/** If client update is within MAXPOSITIONERRORSQUARED of what the server expects then the client is authoritative on it's final position */
	UPROPERTY(GlobalConfig)
	bool ClientAuthorativePosition;

	//======================================================================================================================
	// Movement Time Discrepancy settings for Characters (speed hack detection and prevention)

	/** Whether movement time discrepancy (speed hack) detection is enabled. */
	UPROPERTY(GlobalConfig)

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Classes/GameFramework/GameNetworkManager.h:239

Scope (from outer to inner):

file
class        class AGameNetworkManager : public AInfo

Source code excerpt:

	/** 
	 * Whether client moves should be force corrected during time discrepancy resolution, useful for projects that have lenient 
	 * move error tolerance/ClientAuthorativePosition enabled.
	 */
	UPROPERTY(GlobalConfig)
	bool bMovementTimeDiscrepancyForceCorrectionsDuringResolution;

	/**  Update network speeds for listen servers based on number of connected players.  */
	ENGINE_API virtual void UpdateNetSpeeds(bool bIsLanMatch);

	/** Timer which calls UpdateNetSpeeds() once a second. */
	ENGINE_API virtual void UpdateNetSpeedsTimer();

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

Scope (from outer to inner):

file
function     void UCharacterMovementComponent::ProcessClientTimeStampForTimeDiscrepancy

Source code excerpt:

		{
			// Optionally force client corrections during time discrepancy resolution
			// This is useful when default project movement error checking is lenient or ClientAuthorativePosition is enabled
			// to ensure time discrepancy resolution is enforced
			if (GameNetworkManager->bMovementTimeDiscrepancyForceCorrectionsDuringResolution)
			{
				ServerData.bForceClientUpdate = true;
			}

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

Scope (from outer to inner):

file
function     bool UCharacterMovementComponent::ServerShouldUseAuthoritativePosition

Source code excerpt:


	const AGameNetworkManager* GameNetworkManager = (const AGameNetworkManager*)(AGameNetworkManager::StaticClass()->GetDefaultObject());
	if (GameNetworkManager->ClientAuthorativePosition)
	{
		return true;
	}

	return false;
}

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/GameNetworkManager.cpp:38

Scope (from outer to inner):

file
function     AGameNetworkManager::AGameNetworkManager

Source code excerpt:

	ClientNetSendMoveThrottleAtNetSpeed = 10000;
	ClientNetSendMoveThrottleOverPlayerCount = 10;
	ClientAuthorativePosition = false;
	ClientErrorUpdateRateLimit = 0.0f;
	ClientNetCamUpdateDeltaTime = 0.0166f;
	ClientNetCamUpdatePositionLimit = 1000.0f;
	bMovementTimeDiscrepancyDetection = false;
	bMovementTimeDiscrepancyResolution = false;
	MovementTimeDiscrepancyMaxTimeMargin = 0.25f;