p.NetVisualizeSimulatedCorrections

p.NetVisualizeSimulatedCorrections

#Overview

name: p.NetVisualizeSimulatedCorrections

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

It is referenced in 5 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of p.NetVisualizeSimulatedCorrections is to enable visualization of simulated corrections in the character movement component of Unreal Engine 5. This setting variable is primarily used for debugging and visual inspection of network-related character movement adjustments.

This setting variable is used within the Character Movement Component of Unreal Engine’s gameplay framework. It’s specifically utilized in the UCharacterMovementComponent class, which is responsible for managing character movement in networked environments.

The value of this variable is set through the console variable system in Unreal Engine. It’s defined as an FAutoConsoleVariableRef, which allows it to be modified at runtime through console commands.

The associated variable NetVisualizeSimulatedCorrections interacts directly with p.NetVisualizeSimulatedCorrections. They share the same value and are used interchangeably in the code.

Developers should be aware that this variable is intended for debugging purposes and is marked with the ECVF_Cheat flag. This means it should not be used or relied upon in production builds of the game.

Best practices when using this variable include:

  1. Only enable it during development and debugging sessions.
  2. Use it in conjunction with other debugging tools to get a comprehensive view of character movement and network corrections.
  3. Be aware of the performance impact when enabled, especially at higher settings (2 or 3).

Regarding the associated variable NetVisualizeSimulatedCorrections:

When using NetVisualizeSimulatedCorrections, developers should:

  1. Understand the different visualization levels and what they represent.
  2. Use it judiciously, as higher levels (2 and 3) may have more significant performance impacts.
  3. Remember to disable it when not needed to avoid any potential impact on performance or behavior in non-development builds.

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

Scope (from outer to inner):

file
namespace    CharacterMovementCVars

Source code excerpt:

	static int32 NetVisualizeSimulatedCorrections = 0;
	FAutoConsoleVariableRef CVarNetVisualizeSimulatedCorrections(
		TEXT("p.NetVisualizeSimulatedCorrections"),
		NetVisualizeSimulatedCorrections,
		TEXT("")
		TEXT("0: Disable, 1: Enable"),
		ECVF_Cheat);

	static int32 DebugTimeDiscrepancy = 0;

#Associated Variable and Callsites

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

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

Scope (from outer to inner):

file
namespace    CharacterMovementCVars

Source code excerpt:

		ECVF_Cheat);

	static int32 NetVisualizeSimulatedCorrections = 0;
	FAutoConsoleVariableRef CVarNetVisualizeSimulatedCorrections(
		TEXT("p.NetVisualizeSimulatedCorrections"),
		NetVisualizeSimulatedCorrections,
		TEXT("")
		TEXT("0: Disable, 1: Enable"),
		ECVF_Cheat);

	static int32 DebugTimeDiscrepancy = 0;
	FAutoConsoleVariableRef CVarDebugTimeDiscrepancy(

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

Scope (from outer to inner):

file
function     void UCharacterMovementComponent::SmoothCorrection

Source code excerpt:


#if !(UE_BUILD_SHIPPING || UE_BUILD_TEST)
		if ( CharacterMovementCVars::NetVisualizeSimulatedCorrections >= 2 )
		{
			const float Radius		= 4.0f;
			const bool	bPersist	= false;
			const float Lifetime	= 10.0f;
			const int32	Sides		= 8;
			const float ArrowSize	= 4.0f;

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

Scope (from outer to inner):

file
function     void UCharacterMovementComponent::SmoothClientPosition_Interpolate

Source code excerpt:

#if !(UE_BUILD_SHIPPING || UE_BUILD_TEST)
			// Show lerp percent
			if ( CharacterMovementCVars::NetVisualizeSimulatedCorrections >= 1 )
			{
				const FColor DebugColor = FColor::White;
				const FVector DebugLocation = CharacterOwner->GetMesh()->GetComponentLocation() + FVector( 0.f, 0.f, 130.0f ) - CharacterOwner->GetBaseTranslationOffset();
				FString DebugText = FString::Printf( TEXT( "Lerp: %2.2f" ), LerpPercent );
				DrawDebugString( GetWorld(), DebugLocation, DebugText, nullptr, DebugColor, 0.f, true );
				FString TimeText = FString::Printf( TEXT("ClientTime: %2.2f ServerTime: %2.2f" ), ClientData->SmoothingClientTimeStamp, ClientData->SmoothingServerTimeStamp);

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

Scope (from outer to inner):

file
function     void UCharacterMovementComponent::SmoothClientPosition_Interpolate

Source code excerpt:

		//	*GetNameSafe(CharacterOwner), *ClientData->MeshTranslationOffset.ToString(), *ClientData->MeshRotationOffset.ToString());

		if ( CharacterMovementCVars::NetVisualizeSimulatedCorrections >= 1 )
		{
			const FVector DebugLocation = CharacterOwner->GetMesh()->GetComponentLocation() + FVector( 0.f, 0.f, 300.0f ) - CharacterOwner->GetBaseTranslationOffset();
			DrawDebugBox( GetWorld(), DebugLocation, FVector( 45, 45, 45 ), CharacterOwner->GetMesh()->GetComponentQuat(), FColor( 0, 255, 0 ) );

			//DrawDebugCoordinateSystem( GetWorld(), UpdatedComponent->GetComponentLocation() + FVector( 0, 0, 300.0f ), UpdatedComponent->GetComponentRotation(), 45.0f );
			//DrawDebugBox( GetWorld(), UpdatedComponent->GetComponentLocation() + FVector( 0, 0, 300.0f ), FVector( 45, 45, 45 ), UpdatedComponent->GetComponentQuat(), FColor( 0, 255, 0 ) );

			if ( CharacterMovementCVars::NetVisualizeSimulatedCorrections >= 3 )
			{
				ClientData->SimulatedDebugDrawTime += DeltaSeconds;

				if ( ClientData->SimulatedDebugDrawTime >= 1.0f / 60.0f )
				{
					const float Radius		= 2.0f;