bMovementTimeDiscrepancyDetection
bMovementTimeDiscrepancyDetection
#Overview
name: bMovementTimeDiscrepancyDetection
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 bMovementTimeDiscrepancyDetection is to enable or disable the detection of movement time discrepancies, which are often associated with speed hacks in networked gameplay.
This setting variable is primarily used in the game networking and character movement systems of Unreal Engine. Based on the callsites, it’s utilized in the GameNetworkManager and CharacterMovementComponent, which are part of the Engine module.
The value of this variable is set in the GameNetworkManager constructor, where it’s initialized to false. It can be modified through engine configuration files, as indicated by the UPROPERTY(GlobalConfig) decorator in the GameNetworkManager class definition.
bMovementTimeDiscrepancyDetection interacts closely with other variables like bMovementTimeDiscrepancyResolution, MovementTimeDiscrepancyMaxTimeMargin, and MovementTimeDiscrepancyMinTimeMargin. These variables work together to detect and potentially resolve movement time discrepancies.
Developers must be aware that enabling this feature can impact performance and may cause false positives in certain network conditions. It should be thoroughly tested in various network scenarios before being enabled in production.
Best practices when using this variable include:
- Only enable it if cheating through speed hacks is a significant concern in your game.
- Use it in conjunction with bMovementTimeDiscrepancyResolution for a complete anti-cheat solution.
- Carefully tune the associated margin and resolution rate variables to balance between cheat detection and legitimate player experience.
- Consider the impact on player experience, especially for those with less stable internet connections.
- Implement server-side validation of important game state to complement this client-side detection mechanism.
#Setting Variables
#References In INI files
Location: <Workspace>/Engine/Config/BaseGame.ini:40, section: [/Script/Engine.GameNetworkManager]
- INI Section:
/Script/Engine.GameNetworkManager
- Raw value:
false
- 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:193
Scope (from outer to inner):
file
class class AGameNetworkManager : public AInfo
Source code excerpt:
/** Whether movement time discrepancy (speed hack) detection is enabled. */
UPROPERTY(GlobalConfig)
bool bMovementTimeDiscrepancyDetection;
/** Whether movement time discrepancy resolution is enabled (when detected, make client movement "pay back" excessive time discrepancies) */
UPROPERTY(GlobalConfig)
bool bMovementTimeDiscrepancyResolution;
/** Maximum time client can be ahead before triggering movement time discrepancy detection/resolution (if enabled). */
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/Components/CharacterMovementComponent.cpp:9062
Scope (from outer to inner):
file
function void UCharacterMovementComponent::ProcessClientTimeStampForTimeDiscrepancy
Source code excerpt:
const bool bServerMoveHasOccurred = ServerData.ServerTimeStampLastServerMove != 0.f;
const AGameNetworkManager* GameNetworkManager = (const AGameNetworkManager*)(AGameNetworkManager::StaticClass()->GetDefaultObject());
if (GameNetworkManager != nullptr && GameNetworkManager->bMovementTimeDiscrepancyDetection && bServerMoveHasOccurred)
{
const float WorldTimeSeconds = GetWorld()->GetTimeSeconds();
const float ServerDelta = (WorldTimeSeconds - ServerData.ServerTimeStamp) * CharacterOwner->CustomTimeDilation;
const float ClientDelta = ClientTimeStamp - ServerData.CurrentClientTimeStamp;
const float ClientError = ClientDelta - ServerDelta; // Difference between how much time client has ticked since last move vs server
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/GameNetworkManager.cpp:42
Scope (from outer to inner):
file
function AGameNetworkManager::AGameNetworkManager
Source code excerpt:
ClientNetCamUpdateDeltaTime = 0.0166f;
ClientNetCamUpdatePositionLimit = 1000.0f;
bMovementTimeDiscrepancyDetection = false;
bMovementTimeDiscrepancyResolution = false;
MovementTimeDiscrepancyMaxTimeMargin = 0.25f;
MovementTimeDiscrepancyMinTimeMargin = -0.25f;
MovementTimeDiscrepancyResolutionRate = 1.0f;
MovementTimeDiscrepancyDriftAllowance = 0.0f;
bMovementTimeDiscrepancyForceCorrectionsDuringResolution = false;