p.DebugTimeDiscrepancy

p.DebugTimeDiscrepancy

#Overview

name: p.DebugTimeDiscrepancy

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

It is referenced in 4 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of p.DebugTimeDiscrepancy is to enable logging of detailed Movement Time Discrepancy values for testing and debugging purposes in the Character Movement Component of Unreal Engine 5.

This setting variable is primarily used in the Character Movement system, specifically within the UCharacterMovementComponent class. It’s part of the Engine module and is utilized for debugging network-related movement issues.

The value of this variable is set through the Unreal Engine console variable system. It’s defined as an FAutoConsoleVariableRef, which means it can be changed at runtime through the console or configuration files.

The p.DebugTimeDiscrepancy variable interacts directly with the associated variable DebugTimeDiscrepancy. They share the same value, with p.DebugTimeDiscrepancy being the console-accessible name and DebugTimeDiscrepancy being the actual variable used in the code.

Developers must be aware that this variable is only available in non-shipping and non-test builds (it’s wrapped in #if !(UE_BUILD_SHIPPING || UE_BUILD_TEST) preprocessor directives). It’s intended for development and debugging purposes only.

Best practices when using this variable include:

  1. Use it only during development and testing phases.
  2. Be cautious about performance impact when enabling logging, especially at higher verbosity levels.
  3. Use in conjunction with other debugging tools to get a comprehensive view of movement issues.

The associated variable DebugTimeDiscrepancy is an integer that controls the level of logging:

This variable is used in the ProcessClientTimeStampForTimeDiscrepancy function to conditionally log information about time discrepancies in networked character movement. When set to 1 or higher, it logs details about client errors, time discrepancies, and other relevant values. When set to 2, it also logs information about time discrepancy resolution.

Developers should use this variable judiciously, as excessive logging can impact performance. It’s most useful when investigating specific network-related movement issues in multiplayer games.

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

Scope (from outer to inner):

file
namespace    CharacterMovementCVars

Source code excerpt:

	static int32 DebugTimeDiscrepancy = 0;
	FAutoConsoleVariableRef CVarDebugTimeDiscrepancy(
		TEXT("p.DebugTimeDiscrepancy"),
		DebugTimeDiscrepancy,
		TEXT("Whether to log detailed Movement Time Discrepancy values for testing")
		TEXT("0: Disable, 1: Enable Detection logging, 2: Enable Detection and Resolution logging"),
		ECVF_Cheat);
#endif // !(UE_BUILD_SHIPPING || UE_BUILD_TEST)
}

#Associated Variable and Callsites

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

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

Scope (from outer to inner):

file
namespace    CharacterMovementCVars

Source code excerpt:

		ECVF_Cheat);

	static int32 DebugTimeDiscrepancy = 0;
	FAutoConsoleVariableRef CVarDebugTimeDiscrepancy(
		TEXT("p.DebugTimeDiscrepancy"),
		DebugTimeDiscrepancy,
		TEXT("Whether to log detailed Movement Time Discrepancy values for testing")
		TEXT("0: Disable, 1: Enable Detection logging, 2: Enable Detection and Resolution logging"),
		ECVF_Cheat);
#endif // !(UE_BUILD_SHIPPING || UE_BUILD_TEST)
}

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

Scope (from outer to inner):

file
function     void UCharacterMovementComponent::ProcessClientTimeStampForTimeDiscrepancy

Source code excerpt:

#if !(UE_BUILD_SHIPPING || UE_BUILD_TEST)
		// Per-frame spew of time discrepancy-related values - useful for investigating state of time discrepancy tracking
		if (CharacterMovementCVars::DebugTimeDiscrepancy > 0)
		{
			UE_LOG(LogNetPlayerMovement, Warning, TEXT("TimeDiscrepancyDetection: ClientError: %f, TimeDiscrepancy: %f, LifetimeRawTimeDiscrepancy: %f (Lifetime %f), Resolving: %d, ClientDelta: %f, ServerDelta: %f, ClientTimeStamp: %f"),
				ClientError, ServerData.TimeDiscrepancy, ServerData.LifetimeRawTimeDiscrepancy, WorldTimeSeconds - ServerData.WorldCreationTime, ServerData.bResolvingTimeDiscrepancy, ClientDelta, ServerDelta, ClientTimeStamp);
		}
#endif // !(UE_BUILD_SHIPPING || UE_BUILD_TEST)

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

Scope (from outer to inner):

file
function     void UCharacterMovementComponent::ProcessClientTimeStampForTimeDiscrepancy

Source code excerpt:

#if !(UE_BUILD_SHIPPING || UE_BUILD_TEST)
			// Per-frame spew of time discrepancy resolution related values - useful for investigating state of time discrepancy tracking
			if (CharacterMovementCVars::DebugTimeDiscrepancy > 1)
			{
				UE_LOG(LogNetPlayerMovement, Warning, TEXT("TimeDiscrepancyResolution: DeltaOverride: %f, TimeToPayBack: %f, BaseDelta: %f, ServerDeltaSinceLastMovementUpdate: %f, TimeDiscrepancyAccumulatedClientDeltasSinceLastServerTick: %f"),
					ServerData.TimeDiscrepancyResolutionMoveDeltaOverride, TimeToPayBack, BaseDeltaTime, ServerDeltaSinceLastMovementUpdate, ServerData.TimeDiscrepancyAccumulatedClientDeltasSinceLastServerTick);
			}
#endif // !(UE_BUILD_SHIPPING || UE_BUILD_TEST)
		}