MAXPOSITIONERRORSQUARED
MAXPOSITIONERRORSQUARED
#Overview
name: MAXPOSITIONERRORSQUARED
The value of this variable can be defined or overridden in .ini config files. 1
.ini config file referencing this setting variable.
It is referenced in 3
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of MAXPOSITIONERRORSQUARED is to define the maximum allowable squared position error for network play in Unreal Engine. It is used as a threshold to determine when position corrections should be applied to networked actors.
This setting variable is primarily used by the Unreal Engine’s networking system, specifically within the GameFramework module. It is utilized by the AGameNetworkManager class, which handles various network-related settings and calculations.
The value of MAXPOSITIONERRORSQUARED is initially set in the constructor of AGameNetworkManager to 3.0f. However, it is declared with the UPROPERTY(GlobalConfig) macro, which means it can be modified through configuration files, allowing developers to adjust it without recompiling the engine.
MAXPOSITIONERRORSQUARED interacts closely with another variable, MAXNEARZEROVELOCITYSQUARED, which defines the squared velocity threshold for considering an object as stationary in network play.
Developers must be aware that this variable directly impacts the tolerance for position discrepancies in networked gameplay. A higher value will result in less frequent position corrections, potentially leading to smoother but less accurate gameplay, while a lower value will cause more frequent corrections, potentially increasing network traffic but improving accuracy.
Best practices when using this variable include:
- Carefully tuning the value based on the specific requirements of your game, considering factors like game genre, movement speed, and network conditions.
- Testing thoroughly with various network conditions to ensure optimal gameplay experience.
- Considering the trade-off between smooth gameplay and precise positioning when adjusting this value.
- Using it in conjunction with other network-related settings for a comprehensive network optimization strategy.
- Documenting any changes made to this value in project documentation to ensure consistency across the development team.
#Setting Variables
#References In INI files
Location: <Workspace>/Engine/Config/BaseGame.ini:24, section: [/Script/Engine.GameNetworkManager]
- INI Section:
/Script/Engine.GameNetworkManager
- Raw value:
3.0f
- Is Array:
False
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Classes/GameFramework/GameNetworkManager.h:114
Scope (from outer to inner):
file
class class AGameNetworkManager : public AInfo
Source code excerpt:
/** MAXPOSITIONERRORSQUARED is the square of the max position error that is accepted (not corrected) in net play */
UPROPERTY(GlobalConfig)
float MAXPOSITIONERRORSQUARED;
/** MAXNEARZEROVELOCITYSQUARED is the square of the max velocity that is considered zero (not corrected) in net play */
UPROPERTY(GlobalConfig)
float MAXNEARZEROVELOCITYSQUARED;
/** CLIENTADJUSTUPDATECOST is the bandwidth cost in bytes of sending a client adjustment update. 180 is greater than the actual cost, but represents a tweaked value reserving enough bandwidth for
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/GameNetworkManager.cpp:24
Scope (from outer to inner):
file
function AGameNetworkManager::AGameNetworkManager
Source code excerpt:
MoveRepSize = 42.0f;
MAXPOSITIONERRORSQUARED = 3.0f;
MAXNEARZEROVELOCITYSQUARED = 9.0f;
CLIENTADJUSTUPDATECOST = 180.0f;
MAXCLIENTUPDATEINTERVAL = 0.25f;
MaxClientForcedUpdateDuration=1.0f;
ServerForcedUpdateHitchThreshold = 0.150f;
ServerForcedUpdateHitchCooldown = 0.100f;
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/GameNetworkManager.cpp:163
Scope (from outer to inner):
file
function bool AGameNetworkManager::ExceedsAllowablePositionError
Source code excerpt:
bool AGameNetworkManager::ExceedsAllowablePositionError(FVector LocDiff) const
{
return (LocDiff | LocDiff) > GetDefault<AGameNetworkManager>(GetClass())->MAXPOSITIONERRORSQUARED;
}
bool AGameNetworkManager::NetworkVelocityNearZero(FVector InVelocity) const
{
return InVelocity.SizeSquared() < GetDefault<AGameNetworkManager>(GetClass())->MAXNEARZEROVELOCITYSQUARED;
}