bMovementTimeDiscrepancyResolution

bMovementTimeDiscrepancyResolution

#Overview

name: bMovementTimeDiscrepancyResolution

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 3 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of bMovementTimeDiscrepancyResolution is to enable or disable the resolution of movement time discrepancies between the client and server in networked gameplay. This setting is part of Unreal Engine’s network synchronization and movement prediction system.

This setting variable is primarily used in the Engine module, specifically within the GameFramework and character movement systems. The GameNetworkManager and CharacterMovementComponent rely on this variable to manage network synchronization for character movement.

The value of this variable is initially set in the AGameNetworkManager constructor (GameNetworkManager.cpp) to false. However, it is declared as a UPROPERTY with the GlobalConfig flag, which means its value can be overridden in the project’s configuration files.

This variable interacts closely with other movement time discrepancy-related variables, such as:

Developers must be aware that enabling this variable will cause the client’s movement to “pay back” excessive time discrepancies when detected. This can result in visible corrections to the client’s position, which might affect gameplay smoothness if not carefully tuned.

Best practices when using this variable include:

  1. Carefully consider whether to enable it based on your game’s requirements for movement accuracy vs. perceived smoothness.
  2. If enabled, fine-tune the related variables (like MaxTimeMargin and ResolutionRate) to achieve a balance between accuracy and player experience.
  3. Test thoroughly in various network conditions to ensure the resolution doesn’t negatively impact gameplay.
  4. Consider providing visual feedback to players when significant corrections occur to avoid confusion.
  5. Use in conjunction with other network optimization techniques to minimize the occurrence of large discrepancies.

#Setting Variables

#References In INI files

Location: <Workspace>/Engine/Config/BaseGame.ini:41, 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/GameNetworkManager.h:197

Scope (from outer to inner):

file
class        class AGameNetworkManager : public AInfo

Source code excerpt:

	/** Whether movement time discrepancy resolution is enabled (when detected, make client movement "pay back" excessive time discrepancies) */
	UPROPERTY(GlobalConfig)
	bool bMovementTimeDiscrepancyResolution;

	/** Maximum time client can be ahead before triggering movement time discrepancy detection/resolution (if enabled). */
	UPROPERTY(GlobalConfig)
	float MovementTimeDiscrepancyMaxTimeMargin;

	/** Maximum time client can be behind. */

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

Scope (from outer to inner):

file
function     void UCharacterMovementComponent::ProcessClientTimeStampForTimeDiscrepancy

Source code excerpt:


				// Trigger logic for resolving time discrepancies
				if (GameNetworkManager->bMovementTimeDiscrepancyResolution)
				{
					// Trigger Resolution
					ServerData.bResolvingTimeDiscrepancy = true;

					// Transfer calculated error to official TimeDiscrepancy value, which is the time that will be resolved down
					// in this and subsequent moves until it reaches 0 (meaning we equalize the error)

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

Scope (from outer to inner):

file
function     AGameNetworkManager::AGameNetworkManager

Source code excerpt:

	ClientNetCamUpdatePositionLimit = 1000.0f;
	bMovementTimeDiscrepancyDetection = false;
	bMovementTimeDiscrepancyResolution = false;
	MovementTimeDiscrepancyMaxTimeMargin = 0.25f;
	MovementTimeDiscrepancyMinTimeMargin = -0.25f;
	MovementTimeDiscrepancyResolutionRate = 1.0f;
	MovementTimeDiscrepancyDriftAllowance = 0.0f;
	bMovementTimeDiscrepancyForceCorrectionsDuringResolution = false;
	bUseDistanceBasedRelevancy = true;