MovementTimeDiscrepancyMinTimeMargin

MovementTimeDiscrepancyMinTimeMargin

#Overview

name: MovementTimeDiscrepancyMinTimeMargin

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 MovementTimeDiscrepancyMinTimeMargin is to set the minimum allowable time discrepancy between the client and server in networked gameplay, specifically for character movement. This variable is part of the network synchronization system in Unreal Engine 5.

This setting variable is primarily used by the Engine’s networking and movement systems. Based on the callsites, it’s utilized in the GameFramework module, particularly within the GameNetworkManager and CharacterMovementComponent classes.

The value of this variable is set in the AGameNetworkManager constructor with a default value of -0.25f. It can be modified through the engine’s configuration system, as indicated by the UPROPERTY(GlobalConfig) decorator in the GameNetworkManager class definition.

MovementTimeDiscrepancyMinTimeMargin interacts with other time discrepancy-related variables such as MovementTimeDiscrepancyMaxTimeMargin and MovementTimeDiscrepancyResolutionRate. Together, these variables control how the engine handles and corrects timing differences between client and server during networked gameplay.

Developers must be aware that this variable represents the maximum amount of time a client can be behind the server. A negative value indicates that the client is allowed to be slightly behind the server’s time. This setting is crucial for maintaining smooth gameplay experiences in networked environments where latency is present.

Best practices when using this variable include:

  1. Carefully tuning it alongside other time discrepancy variables to achieve the right balance between responsiveness and consistency across the network.
  2. Considering the typical latency of your target audience when setting this value.
  3. Testing thoroughly with various network conditions to ensure it provides a good experience for all players.
  4. Being cautious when modifying this value, as it can significantly impact the feel of the game and the fairness of player interactions.
  5. Documenting any changes made to this variable and the reasoning behind them for future reference and debugging.

#Setting Variables

#References In INI files

Location: <Workspace>/Engine/Config/BaseGame.ini:43, section: [/Script/Engine.GameNetworkManager]

#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:205

Scope (from outer to inner):

file
class        class AGameNetworkManager : public AInfo

Source code excerpt:

	/** Maximum time client can be behind. */
	UPROPERTY(GlobalConfig)
	float MovementTimeDiscrepancyMinTimeMargin;

	/** 
	 * During time discrepancy resolution, we "pay back" the time discrepancy at this rate for future moves until total error is zero.
	 * 1.0 = 100% resolution rate, meaning the next X ServerMoves from the client are fully paying back the time, 
	 * 0.5 = 50% resolution rate, meaning future ServerMoves will spend 50% of tick continuing to move the character and 50% paying back.
	 * Lowering from 100% could be used to produce less severe/noticeable corrections, although typically we would want to correct

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/Components/CharacterMovementComponent.cpp:9097

Scope (from outer to inner):

file
function     void UCharacterMovementComponent::ProcessClientTimeStampForTimeDiscrepancy

Source code excerpt:

			// Never go below MinTimeMargin - ClientError being negative means the client is BEHIND
			// the server (they are going slower).
			NewTimeDiscrepancy = FMath::Max(NewTimeDiscrepancy, GameNetworkManager->MovementTimeDiscrepancyMinTimeMargin);
		}

		// Determine EffectiveClientError, which is error for the currently-being-processed move after 
		// drift allowances/clamping/resolution mode modifications.
		// We need to know how much the current move contributed towards actionable error so that we don't
		// count error that the server never allowed to impact movement to matter

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/GameNetworkManager.cpp:45

Scope (from outer to inner):

file
function     AGameNetworkManager::AGameNetworkManager

Source code excerpt:

	bMovementTimeDiscrepancyResolution = false;
	MovementTimeDiscrepancyMaxTimeMargin = 0.25f;
	MovementTimeDiscrepancyMinTimeMargin = -0.25f;
	MovementTimeDiscrepancyResolutionRate = 1.0f;
	MovementTimeDiscrepancyDriftAllowance = 0.0f;
	bMovementTimeDiscrepancyForceCorrectionsDuringResolution = false;
	bUseDistanceBasedRelevancy = true;
}