a.AnimNode.AimOffsetLookAt.Enable

a.AnimNode.AimOffsetLookAt.Enable

#Overview

name: a.AnimNode.AimOffsetLookAt.Enable

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 a.AnimNode.AimOffsetLookAt.Enable is to control the activation of the LookAt AimOffset functionality in Unreal Engine’s animation system.

This setting variable is primarily used within the animation system, specifically in the AnimGraphRuntime module. It’s part of the AimOffsetLookAt feature, which allows characters to adjust their aim or look direction based on a target.

The value of this variable is set as a console variable (CVar) with a default value of 1 (enabled). It can be toggled between 0 (disabled) and 1 (enabled) at runtime.

The variable interacts directly with CVarAimOffsetLookAtEnable, which is the actual TAutoConsoleVariable instance that holds and manages the value. They essentially represent the same setting.

Developers should be aware that this variable can significantly impact character animation behavior. When disabled, the LookAt AimOffset functionality will not be applied, potentially affecting the realism or responsiveness of character aiming or looking animations.

Best practices for using this variable include:

  1. Use it for debugging or performance optimization purposes.
  2. Be cautious when disabling it in a shipping game, as it may affect gameplay or visual quality.
  3. Consider exposing it as a configurable option for end-users if the feature has a noticeable performance impact.

Regarding CVarAimOffsetLookAtEnable:

This is the actual console variable that controls the LookAt AimOffset functionality. It’s defined using TAutoConsoleVariable, which allows it to be changed at runtime through console commands.

The variable is used in the FAnimNode_AimOffsetLookAt::Evaluate_AnyThread function to determine whether the LookAt AimOffset should be applied. If the value is 1, and other conditions are met (bIsLODEnabled and Alpha is relevant), the UpdateFromLookAtTarget function is called to apply the aim offset.

Developers should note that changes to this variable will take effect immediately during runtime, allowing for on-the-fly adjustments to animation behavior. This can be particularly useful for debugging or performance tuning.

When working with CVarAimOffsetLookAtEnable, consider:

  1. Using it in conjunction with CVarAimOffsetLookAtDebug for comprehensive debugging.
  2. Implementing a system to save and restore its value if you want to persist changes across game sessions.
  3. Being mindful of its performance implications, especially in scenes with many characters using the AimOffsetLookAt feature.

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/AnimGraphRuntime/Private/AnimNodes/AnimNode_AimOffsetLookAt.cpp:16

Scope: file

Source code excerpt:

#include UE_INLINE_GENERATED_CPP_BY_NAME(AnimNode_AimOffsetLookAt)

TAutoConsoleVariable<int32> CVarAimOffsetLookAtEnable(TEXT("a.AnimNode.AimOffsetLookAt.Enable"), 1, TEXT("Enable/Disable LookAt AimOffset"));
TAutoConsoleVariable<int32> CVarAimOffsetLookAtDebug(TEXT("a.AnimNode.AimOffsetLookAt.Debug"), 0, TEXT("Toggle LookAt AimOffset debug"));

/////////////////////////////////////////////////////
// FAnimNode_AimOffsetLookAt

void FAnimNode_AimOffsetLookAt::Initialize_AnyThread(const FAnimationInitializeContext& Context)

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/AnimGraphRuntime/Private/AnimNodes/AnimNode_AimOffsetLookAt.cpp:16

Scope: file

Source code excerpt:

#include UE_INLINE_GENERATED_CPP_BY_NAME(AnimNode_AimOffsetLookAt)

TAutoConsoleVariable<int32> CVarAimOffsetLookAtEnable(TEXT("a.AnimNode.AimOffsetLookAt.Enable"), 1, TEXT("Enable/Disable LookAt AimOffset"));
TAutoConsoleVariable<int32> CVarAimOffsetLookAtDebug(TEXT("a.AnimNode.AimOffsetLookAt.Debug"), 0, TEXT("Toggle LookAt AimOffset debug"));

/////////////////////////////////////////////////////
// FAnimNode_AimOffsetLookAt

void FAnimNode_AimOffsetLookAt::Initialize_AnyThread(const FAnimationInitializeContext& Context)

#Loc: <Workspace>/Engine/Source/Runtime/AnimGraphRuntime/Private/AnimNodes/AnimNode_AimOffsetLookAt.cpp:93

Scope (from outer to inner):

file
function     void FAnimNode_AimOffsetLookAt::Evaluate_AnyThread

Source code excerpt:

	BasePose.Evaluate(Context);

	if (bIsLODEnabled && FAnimWeight::IsRelevant(Alpha) && (CVarAimOffsetLookAtEnable.GetValueOnAnyThread() == 1))
	{
		UpdateFromLookAtTarget(Context);

		// Evaluate MeshSpaceRotation additive blendspace
		FPoseContext MeshSpaceRotationAdditivePoseContext(Context);
		FAnimNode_BlendSpacePlayer::Evaluate_AnyThread(MeshSpaceRotationAdditivePoseContext);