np2.TimeDilationEscalation

np2.TimeDilationEscalation

#Overview

name: np2.TimeDilationEscalation

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 np2.TimeDilationEscalation is to control the time dilation behavior in Unreal Engine’s network physics system. It is used to adjust the game’s time flow on the server side to compensate for network latency and ensure smooth gameplay experiences.

This setting variable is primarily used in the Engine module, specifically within the PlayerController component. It is part of the network physics subsystem, which handles synchronization of physics simulations across the network.

The value of this variable is set through an FAutoConsoleVariableRef, which means it can be adjusted at runtime via console commands. Its default value is true.

Several other variables interact with np2.TimeDilationEscalation:

  1. np2.TimeDilationAmount: Determines the base amount of time dilation.
  2. np2.TimeDilationEscalationDecay: Controls the decay rate of escalated time dilation.
  3. np2.TimeDilationEscalationDecayMax: Sets the maximum decay value for escalated time dilation.

Developers must be aware that this variable significantly affects how the game handles network latency compensation. When enabled, it allows for more aggressive time dilation based on the number of ticks that need adjustment.

Best practices when using this variable include:

  1. Testing thoroughly with various network conditions to ensure it improves rather than degrades gameplay experience.
  2. Monitoring its effects on game performance and player perception of responsiveness.
  3. Considering disabling it for certain game modes or scenarios where precise timing is critical.

Regarding the associated variable TimeDilationEscalation:

The purpose of TimeDilationEscalation is to serve as the actual boolean flag that controls the time dilation escalation behavior within the C++ code.

This variable is used directly in the Engine module, specifically in the APlayerController::ServerSendLatestAsyncPhysicsTimestamp_Implementation function.

Its value is set by the np2.TimeDilationEscalation console variable through the FAutoConsoleVariableRef mechanism.

TimeDilationEscalation interacts closely with the other time dilation-related variables mentioned earlier, particularly in determining how the CurrentFrameBufferOffset is calculated and applied.

Developers should be aware that changes to TimeDilationEscalation will directly affect the game’s network physics behavior, potentially impacting gameplay feel and responsiveness.

Best practices for using TimeDilationEscalation include:

  1. Ensuring it’s properly synchronized with the console variable np2.TimeDilationEscalation.
  2. Considering its impact on other network physics calculations and adjustments.
  3. Logging or debugging its effects during network performance optimization efforts.

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/PlayerController.cpp:138

Scope (from outer to inner):

file
namespace    NetworkPhysicsCvars

Source code excerpt:


	bool TimeDilationEscalation = true;
	FAutoConsoleVariableRef CVarTimeDilationEscalation(TEXT("np2.TimeDilationEscalation"), TimeDilationEscalation, TEXT("Server-side CVar, Dilate the time more depending on how many ticks we need to adjust. When set to false we use the set TimeDilationAmount and wait the amount of time it takes to perform correct the offset. When set to true we multiply the TimeDilationAmount with the buffer offset count which will correct the offset in one TimeDilationAmount cycle."));

	float TimeDilationEscalationDecay = 0.05f;
	FAutoConsoleVariableRef CVarTimeDilationEscalationDecay(TEXT("np2.TimeDilationEscalationDecay"), TimeDilationEscalationDecay, TEXT("Value is a multiplier, Default: 0.05. For each escalated TimeDilation amount, also decay by this much. Disable by setting to 0."));

	float TimeDilationEscalationDecayMax = 0.5f;
	FAutoConsoleVariableRef CVarTimeDilationEscalationDecayMax(TEXT("np2.TimeDilationEscalationDecayMax"), TimeDilationEscalationDecayMax, TEXT("Value is a multiplier, Default: 0.5. The max decay value for escalated time dilation. Lower value means higher decay."));

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/PlayerController.cpp:137

Scope (from outer to inner):

file
namespace    NetworkPhysicsCvars

Source code excerpt:

	FAutoConsoleVariableRef CVarTimeDilationAmount(TEXT("np2.TimeDilationAmount"), TimeDilationAmount, TEXT("Server-side CVar, Disable TimeDilation by setting to 0 | Default: 0.01 | Value is in percent where 0.01 = 1% dilation. Example: 1.0/0.01 = 100, meaning that over the time it usually takes to tick 100 physics steps we will tick 99 or 101 depending on if we dilate up or down."));

	bool TimeDilationEscalation = true;
	FAutoConsoleVariableRef CVarTimeDilationEscalation(TEXT("np2.TimeDilationEscalation"), TimeDilationEscalation, TEXT("Server-side CVar, Dilate the time more depending on how many ticks we need to adjust. When set to false we use the set TimeDilationAmount and wait the amount of time it takes to perform correct the offset. When set to true we multiply the TimeDilationAmount with the buffer offset count which will correct the offset in one TimeDilationAmount cycle."));

	float TimeDilationEscalationDecay = 0.05f;
	FAutoConsoleVariableRef CVarTimeDilationEscalationDecay(TEXT("np2.TimeDilationEscalationDecay"), TimeDilationEscalationDecay, TEXT("Value is a multiplier, Default: 0.05. For each escalated TimeDilation amount, also decay by this much. Disable by setting to 0."));

	float TimeDilationEscalationDecayMax = 0.5f;
	FAutoConsoleVariableRef CVarTimeDilationEscalationDecayMax(TEXT("np2.TimeDilationEscalationDecayMax"), TimeDilationEscalationDecayMax, TEXT("Value is a multiplier, Default: 0.5. The max decay value for escalated time dilation. Lower value means higher decay."));

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/PlayerController.cpp:6259

Scope (from outer to inner):

file
function     void APlayerController::ServerSendLatestAsyncPhysicsTimestamp_Implementation

Source code excerpt:

		int32 CurrentFrameBufferOffset = PredictedServerFrame - ActualTimestamp.ServerFrame;

		if (NetworkPhysicsCvars::TimeDilationEscalation == false)
		{
			CurrentFrameBufferOffset = FMath::Clamp(CurrentFrameBufferOffset, -1, 1);
		}
			
		// Calculate desired dilation and send to client
		const float TimeDilationDecay = FMath::Clamp(1.0f - (NetworkPhysicsCvars::TimeDilationEscalationDecay * FMath::Abs(CurrentFrameBufferOffset)), NetworkPhysicsCvars::TimeDilationEscalationDecayMax, 1.0f);