p.Chaos.CharacterGroundConstraint.ExternalMovementThreshold

p.Chaos.CharacterGroundConstraint.ExternalMovementThreshold

#Overview

name: p.Chaos.CharacterGroundConstraint.ExternalMovementThreshold

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 p.Chaos.CharacterGroundConstraint.ExternalMovementThreshold is to control the threshold for external movement in the character ground constraint system within Unreal Engine’s Chaos physics engine. It determines when to update the character’s position relative to the ground based on external forces.

This setting variable is primarily used in the Chaos physics engine, specifically within the character movement and ground constraint subsystem. It’s part of the experimental Chaos physics module in Unreal Engine 5.

The value of this variable is set using an FAutoConsoleVariableRef, which means it can be adjusted at runtime through the console or configuration files. Its default value is 2.0f (2 centimeters).

The associated variable Chaos_CharacterGroundConstraint_ExternalMovementThreshold directly interacts with p.Chaos.CharacterGroundConstraint.ExternalMovementThreshold. They share the same value and are used interchangeably in the code.

Developers must be aware that this threshold affects when the character’s position is updated relative to the ground. If the distance moved is less than this threshold, the current movement target relative to the ground is retained. This can impact the smoothness and responsiveness of character movement, especially when dealing with small external forces or slight ground movements.

Best practices when using this variable include:

  1. Adjusting it carefully to balance between responsive movement and avoiding jittery behavior.
  2. Testing thoroughly with different movement scenarios to ensure it works well for your specific game requirements.
  3. Considering the scale of your game world when setting this value, as 2 cm might be appropriate for realistic scales but could need adjustment for different world scales.

Regarding the associated variable Chaos_CharacterGroundConstraint_ExternalMovementThreshold:

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/Chaos/Character/CharacterGroundConstraintContainer.cpp:13

Scope (from outer to inner):

file
namespace    Chaos
namespace    CVars

Source code excerpt:

		
		float Chaos_CharacterGroundConstraint_ExternalMovementThreshold = 2.0f;
		FAutoConsoleVariableRef CVarChaos_CharacterGroundConstraint_ExternalMovementThreshold(TEXT("p.Chaos.CharacterGroundConstraint.ExternalMovementThreshold"), Chaos_CharacterGroundConstraint_ExternalMovementThreshold, TEXT("If distance moved is less than this then retain current movement target relative to ground."));
	}
	
	FCharacterGroundConstraintContainer::FCharacterGroundConstraintContainer()
		: Base(FCharacterGroundConstraintHandle::StaticType())
		, ConstraintPool(16, 0)
	{

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/Chaos/Character/CharacterGroundConstraintContainer.cpp:12

Scope (from outer to inner):

file
namespace    Chaos
namespace    CVars

Source code excerpt:

		FAutoConsoleVariableRef CVarChaos_CharacterGroundConstraint_InputMovementThreshold(TEXT("p.Chaos.CharacterGroundConstraint.InputMovementThreshold"), Chaos_CharacterGroundConstraint_InputMovementThreshold, TEXT("Minimum per frame input movement distance in cm."));
		
		float Chaos_CharacterGroundConstraint_ExternalMovementThreshold = 2.0f;
		FAutoConsoleVariableRef CVarChaos_CharacterGroundConstraint_ExternalMovementThreshold(TEXT("p.Chaos.CharacterGroundConstraint.ExternalMovementThreshold"), Chaos_CharacterGroundConstraint_ExternalMovementThreshold, TEXT("If distance moved is less than this then retain current movement target relative to ground."));
	}
	
	FCharacterGroundConstraintContainer::FCharacterGroundConstraintContainer()
		: Base(FCharacterGroundConstraintHandle::StaticType())
		, ConstraintPool(16, 0)
	{

#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Public/Chaos/Character/CharacterGroundConstraintContainer.h:19

Scope (from outer to inner):

file
namespace    Chaos
namespace    CVars

Source code excerpt:

	{
		CHAOS_API extern float Chaos_CharacterGroundConstraint_InputMovementThreshold;
		CHAOS_API extern float Chaos_CharacterGroundConstraint_ExternalMovementThreshold;
	}

	class FCharacterGroundConstraintContainer;
	namespace Private
	{
		class FCharacterGroundConstraintContainerSolver;

#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Public/Chaos/Character/CharacterGroundConstraintContainer.h:78

Scope (from outer to inner):

file
namespace    Chaos
class        class FCharacterGroundConstraintHandle final : public TIntrusiveConstraintHandle<FCharacterGroundConstraintHandle>
function     void SetData

Source code excerpt:

			// position based on the previous target to avoid drift
			const float InputMovementThresholdSq = CVars::Chaos_CharacterGroundConstraint_InputMovementThreshold * CVars::Chaos_CharacterGroundConstraint_InputMovementThreshold;
			const float MovementThresholdSq = CVars::Chaos_CharacterGroundConstraint_ExternalMovementThreshold * CVars::Chaos_CharacterGroundConstraint_ExternalMovementThreshold;
			if ((InData.TargetDeltaPosition.SizeSquared() > InputMovementThresholdSq) || ((NewLocalCharacterPosition - LocalCharacterPosition).SizeSquared() > MovementThresholdSq))
			{
				LocalCharacterPosition = NewLocalCharacterPosition;
			}
			else
			{