p.NetEnableMoveCombining

p.NetEnableMoveCombining

#Overview

name: p.NetEnableMoveCombining

This variable is created as a Console Variable (cvar).

It is referenced in 3 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of p.NetEnableMoveCombining is to control whether move combining is enabled on the client side to reduce network bandwidth usage by combining similar character movement updates. This setting is primarily used in the character movement system of Unreal Engine 5.

The Unreal Engine subsystem that relies on this setting variable is the Character Movement Component, which is part of the Engine module. This can be seen from the file path where the variable is defined and used: Engine/Source/Runtime/Engine/Private/Components/CharacterMovementComponent.cpp.

The value of this variable is set using an FAutoConsoleVariableRef, which allows it to be changed at runtime through console commands. By default, it is set to 1 (enabled).

The associated variable NetEnableMoveCombining interacts directly with p.NetEnableMoveCombining. They share the same value, with NetEnableMoveCombining being the actual int32 variable used in the code, while p.NetEnableMoveCombining is the console variable name.

Developers must be aware that this variable affects network performance and bandwidth usage. When enabled (set to 1), it allows the client to combine similar movement updates before sending them to the server, potentially reducing network traffic at the cost of slightly less frequent updates.

Best practices when using this variable include:

  1. Keep it enabled (default value of 1) for most scenarios to optimize network performance.
  2. Consider disabling it (set to 0) if you need more frequent and precise movement updates, but be aware of the potential increase in network traffic.
  3. Test your game with both settings to ensure it behaves as expected in different network conditions.

Regarding the associated variable NetEnableMoveCombining:

#References in C++ code

#Callsites

This variable is referenced in the following C++ source code:

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

Scope (from outer to inner):

file
namespace    CharacterMovementCVars

Source code excerpt:

	static int32 NetEnableMoveCombining = 1;
	FAutoConsoleVariableRef CVarNetEnableMoveCombining(
		TEXT("p.NetEnableMoveCombining"),
		NetEnableMoveCombining,
		TEXT("Whether to enable move combining on the client to reduce bandwidth by combining similar moves.\n")
		TEXT("0: Disable, 1: Enable"),
		ECVF_Default);

	static int32 NetEnableMoveCombiningOnStaticBaseChange = 1;

#Associated Variable and Callsites

This variable is associated with another variable named NetEnableMoveCombining. They share the same value. See the following C++ source code.

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

Scope (from outer to inner):

file
namespace    CharacterMovementCVars

Source code excerpt:

		ECVF_Default);

	static int32 NetEnableMoveCombining = 1;
	FAutoConsoleVariableRef CVarNetEnableMoveCombining(
		TEXT("p.NetEnableMoveCombining"),
		NetEnableMoveCombining,
		TEXT("Whether to enable move combining on the client to reduce bandwidth by combining similar moves.\n")
		TEXT("0: Disable, 1: Enable"),
		ECVF_Default);

	static int32 NetEnableMoveCombiningOnStaticBaseChange = 1;
	FAutoConsoleVariableRef CVarNetEnableMoveCombiningOnStaticBaseChange(

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

Scope (from outer to inner):

file
function     void UCharacterMovementComponent::ReplicateMoveToServer

Source code excerpt:

		ClientData->SavedMoves.Push(NewMovePtr);

		const bool bCanDelayMove = (CharacterMovementCVars::NetEnableMoveCombining != 0) && CanDelaySendingMove(NewMovePtr);
		
		if (bCanDelayMove && ClientData->PendingMove.IsValid() == false)
		{
			// Decide whether to hold off on move
			const float NetMoveDeltaSeconds = FMath::Clamp(GetClientNetSendDeltaTime(PC, ClientData, NewMovePtr), 1.f/120.f, 1.f/5.f);
			const float SecondsSinceLastMoveSent = MyWorld->GetRealTimeSeconds() - ClientData->ClientUpdateRealTime;