Net.RepMovement.DrawDebug

Net.RepMovement.DrawDebug

#Overview

name: Net.RepMovement.DrawDebug

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 Net.RepMovement.DrawDebug is to enable debug drawing for replicated movement in networked games. This setting variable is used in the networking and actor replication system of Unreal Engine.

This setting variable is primarily used in the Engine module, specifically in the actor replication subsystem. It’s referenced in the ActorReplication.cpp file, which handles the replication of actor properties and movement across the network.

The value of this variable is set through a console variable (CVar) system. It’s defined as a TAutoConsoleVariable with an initial value of 0, which means the debug drawing is disabled by default.

The associated variable CVarDrawDebugRepMovement directly interacts with Net.RepMovement.DrawDebug. They share the same value and are used interchangeably in the code.

Developers must be aware that this variable is primarily for debugging purposes and should not be enabled in shipping builds. It’s checked in the OnRep_ReplicatedMovement function of the AActor class, which is called when replicated movement data is received.

Best practices when using this variable include:

  1. Only enable it during development or debugging sessions.
  2. Be cautious of performance impact when enabled, especially in complex scenes with many replicated actors.
  3. Use it in conjunction with other debugging tools to get a comprehensive view of movement replication issues.
  4. Remember to disable it before creating a shipping build.

Regarding the associated variable CVarDrawDebugRepMovement:

This is the actual C++ variable that corresponds to the Net.RepMovement.DrawDebug console variable. It’s defined as a static TAutoConsoleVariable, which means it’s a global variable that can be accessed and modified at runtime through console commands.

The CVarDrawDebugRepMovement variable is used directly in the code to check if debug drawing should be performed. For example, in the OnRep_ReplicatedMovement function, there’s a check:

if (CVarDrawDebugRepMovement->GetInt() > 0)

This condition determines whether to execute the debug drawing code.

Developers should be aware that changes to this variable will take effect immediately during runtime. They can modify it through console commands for quick debugging without recompiling the game.

When using CVarDrawDebugRepMovement, developers should:

  1. Use GetInt() to retrieve its current value in code.
  2. Be aware that it can be changed at runtime, so the behavior of debug drawing can be toggled on and off during gameplay.
  3. Consider adding additional levels of debug information based on the integer value, not just treating it as a boolean.

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/ActorReplication.cpp:176

Scope: file

Source code excerpt:

}

static TAutoConsoleVariable<int32> CVarDrawDebugRepMovement(TEXT("Net.RepMovement.DrawDebug"), 0, TEXT(""), ECVF_Default);

void AActor::OnRep_ReplicatedMovement()
{
	// Since ReplicatedMovement and AttachmentReplication are REPNOTIFY_Always (and OnRep_AttachmentReplication may call OnRep_ReplicatedMovement directly),
	// this check is needed since this can still be called on actors for which bReplicateMovement is false - for example, during fast-forward in replay playback.
	// When this happens, the values in ReplicatedMovement aren't valid, and must be ignored.

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/ActorReplication.cpp:176

Scope: file

Source code excerpt:

}

static TAutoConsoleVariable<int32> CVarDrawDebugRepMovement(TEXT("Net.RepMovement.DrawDebug"), 0, TEXT(""), ECVF_Default);

void AActor::OnRep_ReplicatedMovement()
{
	// Since ReplicatedMovement and AttachmentReplication are REPNOTIFY_Always (and OnRep_AttachmentReplication may call OnRep_ReplicatedMovement directly),
	// this check is needed since this can still be called on actors for which bReplicateMovement is false - for example, during fast-forward in replay playback.
	// When this happens, the values in ReplicatedMovement aren't valid, and must be ignored.

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/ActorReplication.cpp:191

Scope (from outer to inner):

file
function     void AActor::OnRep_ReplicatedMovement

Source code excerpt:


#if !(UE_BUILD_SHIPPING || UE_BUILD_TEST)
		if (CVarDrawDebugRepMovement->GetInt() > 0)
		{
			FColor DebugColor = FColor::Green;
			if (LocalRepMovement.bRepPhysics)
			{
				switch (GetPhysicsReplicationMode())
				{