np2.TimeDilationEscalationDecay
np2.TimeDilationEscalationDecay
#Overview
name: np2.TimeDilationEscalationDecay
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Value is a multiplier, Default: 0.05. For each escalated TimeDilation amount, also decay by this much. Disable by setting to 0.
It is referenced in 3
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of np2.TimeDilationEscalationDecay is to control the decay rate of escalated time dilation in Unreal Engine’s network physics system. It is used to gradually reduce the effect of time dilation as the system corrects timing offsets between the server and clients.
This setting variable is primarily used in the Engine module, specifically within the PlayerController component. It’s part of the network physics system, which handles synchronization and timing adjustments in networked gameplay.
The value of this variable is set as a console variable (CVar) with a default value of 0.05f. It can be modified at runtime through the console or configuration files.
np2.TimeDilationEscalationDecay interacts with several other variables in the network physics system:
- TimeDilationEscalationDecayMax: Sets the maximum decay value for escalated time dilation.
- TimeDilationMax: Defines the maximum value for the time dilation multiplier.
- TimeDilationAmount: Used in calculating the actual time dilation.
Developers should be aware that this variable directly affects how quickly the game corrects timing discrepancies in networked play. A higher value will cause faster decay of time dilation effects, potentially leading to smoother corrections but possibly at the cost of accuracy.
Best practices when using this variable include:
- Testing different values to find the right balance between smooth corrections and accuracy for your specific game.
- Monitoring its effects in conjunction with other time dilation variables.
- Considering network conditions and game-specific requirements when adjusting this value.
Regarding the associated variable TimeDilationEscalationDecay: This is the actual float variable that stores the value set by the console variable np2.TimeDilationEscalationDecay. It’s used in the calculation of time dilation decay in the ServerSendLatestAsyncPhysicsTimestamp_Implementation function of the PlayerController class.
The purpose of TimeDilationEscalationDecay is the same as np2.TimeDilationEscalationDecay - to control the decay rate of escalated time dilation. It’s used directly in the code to calculate the TimeDilationDecay factor, which is then used to adjust the CalculatedTimeDilation.
Developers should be aware that modifying TimeDilationEscalationDecay directly in the code won’t have the same effect as changing the console variable, as the console variable will overwrite this value. Always use the console variable (np2.TimeDilationEscalationDecay) to modify this setting for consistency and to allow for runtime adjustments.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/PlayerController.cpp:141
Scope (from outer to inner):
file
namespace NetworkPhysicsCvars
Source code excerpt:
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."));
float TimeDilationMax = 1.1f;
FAutoConsoleVariableRef CVarTimeDilationMax(TEXT("np2.TimeDilationMax"), TimeDilationMax, TEXT("Max value of the time dilation multiplier."));
#Associated Variable and Callsites
This variable is associated with another variable named TimeDilationEscalationDecay
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/PlayerController.cpp:140
Scope (from outer to inner):
file
namespace NetworkPhysicsCvars
Source code excerpt:
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."));
float TimeDilationMax = 1.1f;
FAutoConsoleVariableRef CVarTimeDilationMax(TEXT("np2.TimeDilationMax"), TimeDilationMax, TEXT("Max value of the time dilation multiplier."));
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/PlayerController.cpp:6265
Scope (from outer to inner):
file
function void APlayerController::ServerSendLatestAsyncPhysicsTimestamp_Implementation
Source code excerpt:
// Calculate desired dilation and send to client
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);
}