np2.TimeDilationMax
np2.TimeDilationMax
#Overview
name: np2.TimeDilationMax
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Max value of the time dilation multiplier.
It is referenced in 3
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of np2.TimeDilationMax is to set the maximum value for the time dilation multiplier in Unreal Engine 5’s network physics system. This setting is used to control the upper limit of time dilation, which affects the simulation speed of physics in networked multiplayer games.
This setting variable is primarily used by the Engine module, specifically within the network physics subsystem. It’s referenced in the PlayerController.cpp file, which is a core component of Unreal Engine’s gameplay framework.
The value of this variable is set using an FAutoConsoleVariableRef, which means it can be adjusted at runtime through console commands or configuration files. The default value is set to 1.1f, allowing for a slight speed-up of physics simulation if needed.
The np2.TimeDilationMax variable interacts closely with other time dilation-related variables, such as np2.TimeDilationMin and np2.TimeDilationAmount. These variables work together to provide a range and granularity for time dilation adjustments.
Developers should be aware that this variable sets an upper bound for time dilation. It’s crucial for maintaining game balance and preventing physics simulations from running too fast, which could lead to unpredictable behavior or exploitation in multiplayer scenarios.
Best practices when using this variable include:
- Carefully considering the implications of allowing time dilation above 1.0 (normal speed).
- Testing thoroughly in multiplayer scenarios to ensure fairness and consistency across different network conditions.
- Using this in conjunction with np2.TimeDilationMin to create a balanced range of possible time dilation values.
- Monitoring performance impacts when adjusting this value, as higher values may increase CPU load for physics calculations.
Regarding the associated variable TimeDilationMax:
The purpose of TimeDilationMax is to store the actual value of the maximum time dilation multiplier. It’s the internal representation of the np2.TimeDilationMax console variable.
This variable is used directly in the APlayerController::ServerSendLatestAsyncPhysicsTimestamp_Implementation function to clamp the calculated time dilation value. This ensures that the time dilation never exceeds the maximum allowed value, even if other calculations might suggest a higher value.
The value of TimeDilationMax is set through the FAutoConsoleVariableRef mechanism, which binds it to the np2.TimeDilationMax console variable. This allows for dynamic updates of the value at runtime.
TimeDilationMax interacts closely with TimeDilationMin and other time dilation-related variables in the network physics calculations.
Developers should be aware that modifying TimeDilationMax directly in code (rather than through the console variable) might lead to inconsistencies with the np2.TimeDilationMax setting. It’s generally better to modify the console variable instead.
Best practices for TimeDilationMax include:
- Treating it as a read-only variable in most code contexts.
- Using it for comparisons and clamping operations related to time dilation.
- Ensuring that any code that relies on maximum time dilation uses this variable rather than hard-coded values.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/PlayerController.cpp:147
Scope (from outer to inner):
file
namespace NetworkPhysicsCvars
Source code excerpt:
float TimeDilationMax = 1.1f;
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;
#Associated Variable and Callsites
This variable is associated with another variable named TimeDilationMax
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/PlayerController.cpp:146
Scope (from outer to inner):
file
namespace NetworkPhysicsCvars
Source code excerpt:
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."));
float TimeDilationMin = 0.9f;
FAutoConsoleVariableRef CVarTimeDilationMin(TEXT("np2.TimeDilationMin"), TimeDilationMin, TEXT("Min value of the time dilation multiplier"));
}
const float RetryClientRestartThrottleTime = 0.5f;
#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);
}
}