p.RootMotion.DebugSourceLifeTime

p.RootMotion.DebugSourceLifeTime

#Overview

name: p.RootMotion.DebugSourceLifeTime

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.RootMotion.DebugSourceLifeTime is to control the duration for which visualized root motion sources persist in the game world for debugging purposes. This setting variable is primarily used in the root motion system of Unreal Engine 5.

This setting variable is relied upon by the Engine module, specifically within the root motion system. It’s used in the RootMotionSource.cpp file, which is part of the character movement and animation subsystems.

The value of this variable is set as a console variable (CVar) with a default value of 6.0 seconds. It can be modified at runtime through console commands or programmatically.

The associated variable CVarDebugRootMotionSourcesLifetime interacts directly with p.RootMotion.DebugSourceLifeTime. They share the same value and purpose.

Developers must be aware that this variable is marked with ECVF_Cheat flag, indicating it’s intended for debugging and testing purposes, not for use in shipping builds. It affects the visualization of root motion sources, which is crucial for debugging character movement and animations.

Best practices when using this variable include:

  1. Use it only during development and debugging phases.
  2. Adjust the value as needed to observe root motion behavior over different time spans.
  3. Remember to disable or remove any code relying on this variable before creating shipping builds.

Regarding the associated variable CVarDebugRootMotionSourcesLifetime:

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/GameFramework/RootMotionSource.cpp:22

Scope: file

Source code excerpt:


static TAutoConsoleVariable<float> CVarDebugRootMotionSourcesLifetime(
	TEXT("p.RootMotion.DebugSourceLifeTime"),
	6.f,
	TEXT("How long a visualized root motion source persists.\n")
	TEXT("Time in seconds each visualized root motion source persists."),
	ECVF_Cheat);

void RootMotionSourceDebug::PrintOnScreen(const ACharacter& InCharacter, const FString& InString)

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/GameFramework/RootMotionSource.cpp:21

Scope: file

Source code excerpt:

	ECVF_Cheat);

static TAutoConsoleVariable<float> CVarDebugRootMotionSourcesLifetime(
	TEXT("p.RootMotion.DebugSourceLifeTime"),
	6.f,
	TEXT("How long a visualized root motion source persists.\n")
	TEXT("Time in seconds each visualized root motion source persists."),
	ECVF_Cheat);

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/GameFramework/RootMotionSource.cpp:778

Scope (from outer to inner):

file
function     void FRootMotionSource_MoveToForce::PrepareRootMotion

Source code excerpt:

		{
			const FVector LocDiff = MoveComponent.UpdatedComponent->GetComponentLocation() - CurrentLocation;
			const float DebugLifetime = CVarDebugRootMotionSourcesLifetime.GetValueOnGameThread();

			// Current
			DrawDebugCapsule(Character.GetWorld(), MoveComponent.UpdatedComponent->GetComponentLocation(), Character.GetSimpleCollisionHalfHeight(), Character.GetSimpleCollisionRadius(), FQuat::Identity, FColor::Red, true, DebugLifetime);

			// Current Target
			DrawDebugCapsule(Character.GetWorld(), CurrentTargetLocation + LocDiff, Character.GetSimpleCollisionHalfHeight(), Character.GetSimpleCollisionRadius(), FQuat::Identity, FColor::Green, true, DebugLifetime);

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/GameFramework/RootMotionSource.cpp:986

Scope (from outer to inner):

file
function     void FRootMotionSource_MoveToDynamicForce::PrepareRootMotion

Source code excerpt:

		{
			const FVector LocDiff = MoveComponent.UpdatedComponent->GetComponentLocation() - CurrentLocation;
			const float DebugLifetime = CVarDebugRootMotionSourcesLifetime.GetValueOnGameThread();

			// Current
			DrawDebugCapsule(Character.GetWorld(), MoveComponent.UpdatedComponent->GetComponentLocation(), Character.GetSimpleCollisionHalfHeight(), Character.GetSimpleCollisionRadius(), FQuat::Identity, FColor::Red, true, DebugLifetime);

			// Current Target
			DrawDebugCapsule(Character.GetWorld(), CurrentTargetLocation + LocDiff, Character.GetSimpleCollisionHalfHeight(), Character.GetSimpleCollisionRadius(), FQuat::Identity, FColor::Green, true, DebugLifetime);

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/GameFramework/RootMotionSource.cpp:1207

Scope (from outer to inner):

file
function     void FRootMotionSource_JumpForce::PrepareRootMotion

Source code excerpt:

			const FVector CurrentTargetLocation = CurrentLocation + (TargetRelativeLocation - CurrentRelativeLocation);
			const FVector LocDiff = MoveComponent.UpdatedComponent->GetComponentLocation() - CurrentLocation;
			const float DebugLifetime = CVarDebugRootMotionSourcesLifetime.GetValueOnGameThread();

			// Current
			DrawDebugCapsule(Character.GetWorld(), MoveComponent.UpdatedComponent->GetComponentLocation(), Character.GetSimpleCollisionHalfHeight(), Character.GetSimpleCollisionRadius(), FQuat::Identity, FColor::Red, true, DebugLifetime);

			// Current Target
			DrawDebugCapsule(Character.GetWorld(), CurrentTargetLocation + LocDiff, Character.GetSimpleCollisionHalfHeight(), Character.GetSimpleCollisionRadius(), FQuat::Identity, FColor::Green, true, DebugLifetime);