np2.NetworkPhysicsPredictionFrameOffset
np2.NetworkPhysicsPredictionFrameOffset
#Overview
name: np2.NetworkPhysicsPredictionFrameOffset
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
(DEPRECATED 5.4, use np2.PredictionAsyncFrameBuffer instead) Additional frame offset to be added to the local to server offset used by network prediction
It is referenced in 3
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of np2.NetworkPhysicsPredictionFrameOffset is to provide an additional frame offset for network prediction in physics simulations. However, it’s important to note that this variable is deprecated as of Unreal Engine 5.4.
This setting variable is primarily used in the network physics prediction system, which is part of the Engine module in Unreal Engine. It’s specifically referenced in the PlayerController.cpp file, indicating its relevance to player-controlled entities in networked environments.
The value of this variable is set to 4 by default, as seen in the source code. It’s defined as a console variable, which means it can be adjusted at runtime through the console or configuration files.
The np2.NetworkPhysicsPredictionFrameOffset interacts closely with another variable called PredictionAsyncFrameBuffer. In fact, PredictionAsyncFrameBuffer is intended to replace NetworkPhysicsPredictionFrameOffset as of UE 5.4.
Developers must be aware that this variable is deprecated and should use np2.PredictionAsyncFrameBuffer instead. The deprecation notice is clearly stated in the comments, indicating that this change occurred in UE 5.4.
Best practices when using this variable:
- Avoid using np2.NetworkPhysicsPredictionFrameOffset in new projects or when updating existing projects to UE 5.4 or later.
- Replace any usage of np2.NetworkPhysicsPredictionFrameOffset with np2.PredictionAsyncFrameBuffer.
- If maintaining older projects, be aware that this variable might be removed in future engine versions.
Regarding the associated variable PredictionAsyncFrameBuffer:
The purpose of PredictionAsyncFrameBuffer is to provide an additional frame offset for network prediction, similar to its deprecated counterpart. It’s the recommended replacement for NetworkPhysicsPredictionFrameOffset.
This variable is also part of the network physics prediction system in the Engine module. It’s defined in the same file (PlayerController.cpp) and context as the deprecated variable.
The default value for PredictionAsyncFrameBuffer is set to 3, which is slightly lower than the deprecated variable’s default of 4.
PredictionAsyncFrameBuffer doesn’t directly interact with other variables in the provided code snippet, but it serves the same purpose as the deprecated NetworkPhysicsPredictionFrameOffset.
Developers should be aware that this is the current recommended variable for adjusting frame offset in network prediction for physics simulations.
Best practices for using PredictionAsyncFrameBuffer:
- Use this variable instead of NetworkPhysicsPredictionFrameOffset in UE 5.4 and later versions.
- Adjust the value carefully, as it affects the balance between prediction accuracy and network performance.
- Test thoroughly with different network conditions to find the optimal value for your specific game requirements.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/PlayerController.cpp:123
Scope (from outer to inner):
file
namespace NetworkPhysicsCvars
Source code excerpt:
/* DEPRECATED 5.4 */
int32 NetworkPhysicsPredictionFrameOffset = 4;
FAutoConsoleVariableRef CVarNetworkPhysicsPredictionFrameOffset(TEXT("np2.NetworkPhysicsPredictionFrameOffset"), NetworkPhysicsPredictionFrameOffset, TEXT("(DEPRECATED 5.4, use np2.PredictionAsyncFrameBuffer instead) Additional frame offset to be added to the local to server offset used by network prediction"));
int32 PredictionAsyncFrameBuffer = 3;
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."));
#Associated Variable and Callsites
This variable is associated with another variable named NetworkPhysicsPredictionFrameOffset
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/PlayerController.cpp:122
Scope (from outer to inner):
file
namespace NetworkPhysicsCvars
Source code excerpt:
/* DEPRECATED 5.4 */
int32 NetworkPhysicsPredictionFrameOffset = 4;
FAutoConsoleVariableRef CVarNetworkPhysicsPredictionFrameOffset(TEXT("np2.NetworkPhysicsPredictionFrameOffset"), NetworkPhysicsPredictionFrameOffset, TEXT("(DEPRECATED 5.4, use np2.PredictionAsyncFrameBuffer instead) Additional frame offset to be added to the local to server offset used by network prediction"));
int32 PredictionAsyncFrameBuffer = 3;
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."));
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/PlayerController.cpp:6303
Scope (from outer to inner):
file
function void APlayerController::ClientCorrectionAsyncPhysicsTimestamp_Implementation
Source code excerpt:
// To deal with that we compute a safe margin based on a user cvar + half the RTT
// This margin will only be applied the first time we will compute the offset
const int32 FrameOffset = LocalToServerAsyncPhysicsTickOffset_DEPRECATED == 0 ? (NetworkPhysicsCvars::NetworkPhysicsPredictionFrameOffset + (CurrentTimestamp.LocalFrame - Timestamp.LocalFrame) / 2) : 0;
const int32 NewOffset = FMath::Max(LocalToServerAsyncPhysicsTickOffset_DEPRECATED, Timestamp.ServerFrame - Timestamp.LocalFrame + FrameOffset); //The new offset as reported by the server
LocalToServerAsyncPhysicsTickOffset_DEPRECATED = NewOffset;
PRAGMA_ENABLE_DEPRECATION_WARNINGS
}