a.AnimNode.LegIK.TargetReachStepPercent

a.AnimNode.LegIK.TargetReachStepPercent

#Overview

name: a.AnimNode.LegIK.TargetReachStepPercent

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

It is referenced in 4 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of a.AnimNode.LegIK.TargetReachStepPercent is to control the step size in the Leg IK (Inverse Kinematics) system within Unreal Engine’s animation system. It determines how quickly the IK solver moves towards the target position during each iteration of the FABRIK (Forward And Backward Reaching Inverse Kinematics) algorithm.

This setting variable is primarily used by the animation system, specifically within the Leg IK node implementation. It’s part of the AnimGraphRuntime module, which is responsible for various animation graph functionalities in Unreal Engine.

The value of this variable is set as a console variable (CVar) with a default value of 0.7f. It can be adjusted at runtime through the console or programmatically.

The associated variable CVarAnimLegIKTargetReachStepPercent directly interacts with a.AnimNode.LegIK.TargetReachStepPercent. They share the same value and purpose.

Developers should be aware that this variable affects the speed and stability of the Leg IK solver. A higher value will make the solver reach the target position more quickly but may lead to instability or jittering. A lower value will make the solver more stable but might require more iterations to reach the target.

Best practices when using this variable include:

  1. Experiment with different values to find the right balance between speed and stability for your specific use case.
  2. Consider exposing this variable as a tunable parameter in your animation blueprints or character settings.
  3. Be cautious when setting extreme values (close to 0 or 1), as they may cause undesirable results.
  4. Monitor performance impact when adjusting this value, especially if you have many characters using Leg IK simultaneously.

Regarding the associated variable CVarAnimLegIKTargetReachStepPercent:

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/AnimGraphRuntime/Private/BoneControllers/AnimNode_LegIK.cpp:17

Scope: file

Source code excerpt:

TAutoConsoleVariable<int32> CVarAnimLegIKEnable(TEXT("a.AnimNode.LegIK.Enable"), 1, TEXT("Toggle LegIK node."));
TAutoConsoleVariable<int32> CVarAnimLegIKMaxIterations(TEXT("a.AnimNode.LegIK.MaxIterations"), 0, TEXT("Leg IK MaxIterations override. 0 = node default, > 0 override."));
TAutoConsoleVariable<float> CVarAnimLegIKTargetReachStepPercent(TEXT("a.AnimNode.LegIK.TargetReachStepPercent"), 0.7f, TEXT("Leg IK TargetReachStepPercent."));
TAutoConsoleVariable<float> CVarAnimLegIKPullDistribution(TEXT("a.AnimNode.LegIK.PullDistribution"), 0.5f, TEXT("Leg IK PullDistribution. 0 = foot, 0.5 = balanced, 1.f = hip"));

/////////////////////////////////////////////////////
// FAnimAnimNode_LegIK

DECLARE_CYCLE_STAT(TEXT("LegIK Eval"), STAT_LegIK_Eval, STATGROUP_Anim);

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/AnimGraphRuntime/Private/BoneControllers/AnimNode_LegIK.cpp:17

Scope: file

Source code excerpt:

TAutoConsoleVariable<int32> CVarAnimLegIKEnable(TEXT("a.AnimNode.LegIK.Enable"), 1, TEXT("Toggle LegIK node."));
TAutoConsoleVariable<int32> CVarAnimLegIKMaxIterations(TEXT("a.AnimNode.LegIK.MaxIterations"), 0, TEXT("Leg IK MaxIterations override. 0 = node default, > 0 override."));
TAutoConsoleVariable<float> CVarAnimLegIKTargetReachStepPercent(TEXT("a.AnimNode.LegIK.TargetReachStepPercent"), 0.7f, TEXT("Leg IK TargetReachStepPercent."));
TAutoConsoleVariable<float> CVarAnimLegIKPullDistribution(TEXT("a.AnimNode.LegIK.PullDistribution"), 0.5f, TEXT("Leg IK PullDistribution. 0 = foot, 0.5 = balanced, 1.f = hip"));

/////////////////////////////////////////////////////
// FAnimAnimNode_LegIK

DECLARE_CYCLE_STAT(TEXT("LegIK Eval"), STAT_LegIK_Eval, STATGROUP_Anim);

#Loc: <Workspace>/Engine/Source/Runtime/AnimGraphRuntime/Private/BoneControllers/AnimNode_LegIK.cpp:579

Scope (from outer to inner):

file
function     void FIKChain::FABRIK_ForwardReach

Source code excerpt:

		EndEffectorToTarget.ToDirectionAndLength(EndEffectorToTargetDir, EndEffectToTargetSize);

		const double ReachStepAlpha = FMath::Clamp(CVarAnimLegIKTargetReachStepPercent.GetValueOnAnyThread(), 0.01, 0.99);

		double Displacement = EndEffectToTargetSize;
		for (int32 LinkIndex = 1; LinkIndex < IKChain.NumLinks; LinkIndex++)
		{
			FVector EndEffectorToParent = IKChain.Links[LinkIndex].Location - IKChain.Links[0].Location;
			double ParentDisplacement = (EndEffectorToParent | EndEffectorToTargetDir);

#Loc: <Workspace>/Engine/Source/Runtime/AnimGraphRuntime/Private/BoneControllers/AnimNode_LegIK.cpp:620

Scope (from outer to inner):

file
function     void FIKChain::FABRIK_BackwardReach

Source code excerpt:

		RootToRootTarget.ToDirectionAndLength(RootToRootTargetDir, RootToRootTargetSize);

		const double ReachStepAlpha = FMath::Clamp(CVarAnimLegIKTargetReachStepPercent.GetValueOnAnyThread(), 0.01, 0.99);

		double Displacement = RootToRootTargetSize;
		for (int32 LinkIndex = IKChain.NumLinks - 2; LinkIndex >= 0; LinkIndex--)
		{
			FVector RootToChild = IKChain.Links[IKChain.NumLinks - 2].Location - IKChain.Links.Last().Location;
			double ChildDisplacement = (RootToChild | RootToRootTargetDir);