np2.TimeDilationMin

np2.TimeDilationMin

#Overview

name: np2.TimeDilationMin

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.TimeDilationMin is to set the minimum value for the time dilation multiplier in Unreal Engine 5’s network physics system. This setting is used to control the lower bound of time dilation, which affects the simulation speed of physics in networked gameplay.

This setting variable is primarily used in the Engine module, specifically within the PlayerController component. It’s part of the network physics subsystem, which is responsible for maintaining consistent physics simulations across networked game instances.

The value of this variable is set using an FAutoConsoleVariableRef, which allows it to be modified at runtime through console commands. It’s initialized with a default value of 0.9f.

The np2.TimeDilationMin variable interacts closely with np2.TimeDilationMax, which sets the upper bound for time dilation. Together, these variables define the range within which time dilation can be adjusted.

Developers must be aware that this variable directly impacts the physics simulation speed in networked games. Setting it too low might cause physics to run too slowly, potentially affecting gameplay and player experience.

Best practices when using this variable include:

  1. Carefully consider the implications of changing this value on gameplay and network performance.
  2. Test thoroughly with various network conditions to ensure smooth gameplay across different scenarios.
  3. Use in conjunction with np2.TimeDilationMax to maintain a balanced range of time dilation.

Regarding the associated variable TimeDilationMin: This is the actual float variable that stores the minimum time dilation value. It’s directly linked to the np2.TimeDilationMin console variable.

The TimeDilationMin variable is used in the APlayerController::ServerSendLatestAsyncPhysicsTimestamp_Implementation function to clamp the calculated time dilation value. This ensures that the time dilation stays within the defined bounds during network physics calculations.

Developers should note that modifying TimeDilationMin directly in code will not affect the console variable. To change the value at runtime, they should use the console variable np2.TimeDilationMin instead.

#References in C++ code

#Callsites

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

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

Scope (from outer to inner):

file
namespace    NetworkPhysicsCvars

Source code excerpt:


	float TimeDilationMin = 0.9f;
	FAutoConsoleVariableRef CVarTimeDilationMin(TEXT("np2.TimeDilationMin"), TimeDilationMin, TEXT("Min value of the time dilation multiplier"));
}

const float RetryClientRestartThrottleTime = 0.5f;
const float RetryServerAcknowledgeThrottleTime = 0.25f;
const float RetryServerCheckSpectatorThrottleTime = 0.25f;

#Associated Variable and Callsites

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

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

Scope (from outer to inner):

file
namespace    NetworkPhysicsCvars

Source code excerpt:

	FAutoConsoleVariableRef CVarTimeDilationMax(TEXT("np2.TimeDilationMax"), TimeDilationMax, TEXT("Max value of the time dilation multiplier."));

	float TimeDilationMin = 0.9f;
	FAutoConsoleVariableRef CVarTimeDilationMin(TEXT("np2.TimeDilationMin"), TimeDilationMin, TEXT("Min value of the time dilation multiplier"));
}

const float RetryClientRestartThrottleTime = 0.5f;
const float RetryServerAcknowledgeThrottleTime = 0.25f;
const float RetryServerCheckSpectatorThrottleTime = 0.25f;

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

Scope (from outer to inner):

file
function     void APlayerController::ServerSendLatestAsyncPhysicsTimestamp_Implementation

Source code excerpt:

		const float TimeDilationDecay = FMath::Clamp(1.0f - (NetworkPhysicsCvars::TimeDilationEscalationDecay * FMath::Abs(CurrentFrameBufferOffset)), NetworkPhysicsCvars::TimeDilationEscalationDecayMax, 1.0f);
		float CalculatedTimeDilation = 1.0f + ((NetworkPhysicsCvars::TimeDilationAmount * -CurrentFrameBufferOffset) * TimeDilationDecay);
		CalculatedTimeDilation = FMath::Clamp(CalculatedTimeDilation, NetworkPhysicsCvars::TimeDilationMin, NetworkPhysicsCvars::TimeDilationMax);

		ClientAckTimeDilation(CalculatedTimeDilation, ActualTimestamp.LocalFrame);
	}
	
}