np2.TickOffsetUpdateInterval
np2.TickOffsetUpdateInterval
#Overview
name: np2.TickOffsetUpdateInterval
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
How many physics ticks to wait between each tick offset update. Lowest viable value = 1, which means update each tick. Deactivate physics offset updates by setting to 0 or negative value.
It is referenced in 3
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of np2.TickOffsetUpdateInterval is to control the frequency of tick offset updates in the network physics system of Unreal Engine 5. It determines how many physics ticks should occur between each update of the tick offset.
This setting variable is primarily used in the networking and physics subsystems of Unreal Engine. Based on the provided code, it appears to be part of the PlayerController module, which is responsible for managing player input and interactions within the game.
The value of this variable is set through an FAutoConsoleVariableRef, which means it can be adjusted at runtime via console commands. The default value is set to 10 in the code.
The associated variable TickOffsetUpdateInterval interacts directly with np2.TickOffsetUpdateInterval, as they share the same value. This variable is used in the UpdateServerAsyncPhysicsTickOffset function of the APlayerController class to determine when to send new timestamp updates to the server.
Developers must be aware that:
- Setting this value to 0 or a negative number will deactivate physics offset updates entirely.
- The lowest viable value is 1, which means updating each tick.
- Higher values will result in less frequent updates, potentially reducing network traffic but at the cost of less precise synchronization.
Best practices when using this variable include:
- Balancing update frequency with network performance. More frequent updates (lower values) provide better synchronization but increase network traffic.
- Testing different values to find the optimal balance for your specific game requirements.
- Considering the relationship with other network physics variables, such as TickOffsetCorrectionLimit and TimeDilationAmount, to ensure smooth gameplay.
Regarding the associated variable TickOffsetUpdateInterval: The purpose of TickOffsetUpdateInterval is to implement the functionality defined by np2.TickOffsetUpdateInterval within the engine’s code. It’s used directly in the UpdateServerAsyncPhysicsTickOffset function to determine when to send new timestamp updates to the server.
This variable is set in the same scope as np2.TickOffsetUpdateInterval and is used in the PlayerController module. Its value is determined by the console variable np2.TickOffsetUpdateInterval.
Developers should be aware that modifying TickOffsetUpdateInterval directly in the code will not have the desired effect, as its value is controlled by the console variable. Instead, they should adjust np2.TickOffsetUpdateInterval to change the behavior of the tick offset update system.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/PlayerController.cpp:129
Scope (from outer to inner):
file
namespace NetworkPhysicsCvars
Source code excerpt:
int32 TickOffsetUpdateInterval = 10;
FAutoConsoleVariableRef CVarTickOffsetUpdateInterval(TEXT("np2.TickOffsetUpdateInterval"), TickOffsetUpdateInterval, TEXT("How many physics ticks to wait between each tick offset update. Lowest viable value = 1, which means update each tick. Deactivate physics offset updates by setting to 0 or negative value."));
int32 TickOffsetCorrectionLimit = 10;
FAutoConsoleVariableRef CVarTickOffsetCorrectionLimit(TEXT("np2.TickOffsetCorrectionLimit"), TickOffsetCorrectionLimit, TEXT("If the client gets out of sync with physics ticks more than this limit, cut the losses and reset the offset."));
float TimeDilationAmount = 0.01f;
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."));
#Associated Variable and Callsites
This variable is associated with another variable named TickOffsetUpdateInterval
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/PlayerController.cpp:128
Scope (from outer to inner):
file
namespace NetworkPhysicsCvars
Source code excerpt:
FAutoConsoleVariableRef CVarPredictionAsyncFrameBuffer(TEXT("np2.PredictionAsyncFrameBuffer"), PredictionAsyncFrameBuffer, TEXT("Additional frame offset to be added to the local to server offset used by network prediction"));
int32 TickOffsetUpdateInterval = 10;
FAutoConsoleVariableRef CVarTickOffsetUpdateInterval(TEXT("np2.TickOffsetUpdateInterval"), TickOffsetUpdateInterval, TEXT("How many physics ticks to wait between each tick offset update. Lowest viable value = 1, which means update each tick. Deactivate physics offset updates by setting to 0 or negative value."));
int32 TickOffsetCorrectionLimit = 10;
FAutoConsoleVariableRef CVarTickOffsetCorrectionLimit(TEXT("np2.TickOffsetCorrectionLimit"), TickOffsetCorrectionLimit, TEXT("If the client gets out of sync with physics ticks more than this limit, cut the losses and reset the offset."));
float TimeDilationAmount = 0.01f;
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."));
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/PlayerController.cpp:6197
Scope (from outer to inner):
file
function void APlayerController::UpdateServerAsyncPhysicsTickOffset
Source code excerpt:
{
FAsyncPhysicsTimestamp Timestamp = GetPhysicsTimestamp();
if (NetworkPhysicsCvars::TickOffsetUpdateInterval <= 0 || ClientLatestAsyncPhysicsStepSent + NetworkPhysicsCvars::TickOffsetUpdateInterval > Timestamp.LocalFrame)
{
//Only send a new timestamp if enough physics ticks have passed, based on CVar.
//If GT is running faster than physics sim the physics timestep will not have changed, so no need to send another update to server
//This ensures monotonic increase
return;
}