p.RigidBodyNode.GravityScale

p.RigidBodyNode.GravityScale

#Overview

name: p.RigidBodyNode.GravityScale

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 p.RigidBodyNode.GravityScale is to control the gravity scale applied to all Rigid Body Animation Nodes (RBANs) in Unreal Engine’s animation system. This setting variable is used to multiply the gravity effect on rigid body simulations within animations.

This setting variable is primarily used in the AnimGraphRuntime module, specifically within the implementation of the Rigid Body Animation Node. It’s part of the animation system in Unreal Engine, which allows for physics-based animations.

The value of this variable is set using an FAutoConsoleVariableRef, which means it can be adjusted at runtime through console commands. Its default value is 1.0f, as seen in the code:

float RBAN_GravityScale = 1.0f;
FAutoConsoleVariableRef CVarRigidBodyNodeGravityScale(TEXT("p.RigidBodyNode.GravityScale"), RBAN_GravityScale, TEXT("Multiplies the gravity on all RBANs"), ECVF_Default);

This variable interacts directly with the RBAN_GravityScale variable, which is used in the actual computation of gravity in the FAnimNode_RigidBody::EvaluateSkeletalControl_AnyThread function:

SimSpaceGravity *= RBAN_GravityScale;

Developers should be aware that changing this variable will affect all Rigid Body Animation Nodes in the project. It’s a global setting that can have wide-ranging effects on physics-based animations.

Best practices when using this variable include:

  1. Use it for global gravity adjustments that should affect all rigid body animations.
  2. Be cautious when modifying it, as it can significantly impact the feel and behavior of animations.
  3. Consider using it for prototyping or quick adjustments, but for more fine-grained control, individual animation settings might be more appropriate.
  4. Document any non-default values used in production to ensure consistency across the development team.

Regarding the associated variable RBAN_GravityScale:

The purpose of RBAN_GravityScale is to store the actual value used for gravity scaling in Rigid Body Animation Nodes. It’s the internal representation of the p.RigidBodyNode.GravityScale console variable.

This variable is used directly in the AnimGraphRuntime module, specifically in the FAnimNode_RigidBody class, which handles rigid body simulations in animations.

The value of RBAN_GravityScale is set through the console variable system, allowing for runtime adjustments. Its default value is 1.0f, representing no scaling of gravity.

RBAN_GravityScale interacts directly with the SimSpaceGravity calculation in the EvaluateSkeletalControl_AnyThread function of FAnimNode_RigidBody.

Developers should be aware that this variable directly affects the physics simulation in animations. Changes to this value will be immediately reflected in all rigid body animations.

Best practices for RBAN_GravityScale include:

  1. Use it as a read-only variable in most cases, as it’s meant to be controlled via the console variable system.
  2. When debugging or prototyping, you can modify this variable directly for immediate effects, but remember to adjust the corresponding console variable for persistent changes.
  3. Be mindful of its global nature - changes will affect all rigid body animations.

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/AnimGraphRuntime/Private/BoneControllers/AnimNode_RigidBody.cpp:88

Scope: file

Source code excerpt:

FAutoConsoleVariableRef CVarRigidBodyNodeOverrideComponentAppliedLinearAccClamp(TEXT("p.RigidBodyNode.ComponentAppliedLinearAccClamp"), RBAN_Override_ComponentAppliedLinearAccClamp, TEXT("ComponentAppliedLinearAccClamp override"), ECVF_Default);
float RBAN_GravityScale = 1.0f;
FAutoConsoleVariableRef CVarRigidBodyNodeGravityScale(TEXT("p.RigidBodyNode.GravityScale"), RBAN_GravityScale, TEXT("Multiplies the gravity on all RBANs"), ECVF_Default);

bool bRBAN_DeferredSimulationDefault = false;
FAutoConsoleVariableRef CVarRigidBodyNodeDeferredSimulationDefault(
	TEXT("p.RigidBodyNode.DeferredSimulationDefault"),
	bRBAN_DeferredSimulationDefault,
	TEXT("Whether rigid body simulations are deferred one frame for assets that don't opt into a specific simulation timing"),

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/AnimGraphRuntime/Private/BoneControllers/AnimNode_RigidBody.cpp:87

Scope: file

Source code excerpt:

FAutoConsoleVariableRef CVarRigidBodyNodeOverrideComponentLinearVelScale(TEXT("p.RigidBodyNode.ComponentLinearVelcale"), RBAN_Override_ComponentLinearVelScale, TEXT("ComponentLinearVelcale override"), ECVF_Default);
FAutoConsoleVariableRef CVarRigidBodyNodeOverrideComponentAppliedLinearAccClamp(TEXT("p.RigidBodyNode.ComponentAppliedLinearAccClamp"), RBAN_Override_ComponentAppliedLinearAccClamp, TEXT("ComponentAppliedLinearAccClamp override"), ECVF_Default);
float RBAN_GravityScale = 1.0f;
FAutoConsoleVariableRef CVarRigidBodyNodeGravityScale(TEXT("p.RigidBodyNode.GravityScale"), RBAN_GravityScale, TEXT("Multiplies the gravity on all RBANs"), ECVF_Default);

bool bRBAN_DeferredSimulationDefault = false;
FAutoConsoleVariableRef CVarRigidBodyNodeDeferredSimulationDefault(
	TEXT("p.RigidBodyNode.DeferredSimulationDefault"),
	bRBAN_DeferredSimulationDefault,
	TEXT("Whether rigid body simulations are deferred one frame for assets that don't opt into a specific simulation timing"),

#Loc: <Workspace>/Engine/Source/Runtime/AnimGraphRuntime/Private/BoneControllers/AnimNode_RigidBody.cpp:794

Scope (from outer to inner):

file
function     void FAnimNode_RigidBody::EvaluateSkeletalControl_AnyThread

Source code excerpt:

			UpdateWorldForces(CompWorldSpaceTM, BaseBoneTM, DeltaSeconds);
			SimSpaceGravity = WorldVectorToSpaceNoScale(SimulationSpace, WorldSpaceGravity, CompWorldSpaceTM, BaseBoneTM);
			SimSpaceGravity *= RBAN_GravityScale;

			FSimSpaceSettings UseSimSpaceSettings = SimSpaceSettings;
			if (bRBAN_SimSpace_EnableOverride)
			{
				if (RBAN_SimSpaceOverride_WorldAlpha >= 0.0f) UseSimSpaceSettings.WorldAlpha = RBAN_SimSpaceOverride_WorldAlpha;
				if (RBAN_SimSpaceOverride_VelocityScaleZ >= 0.0f) UseSimSpaceSettings.VelocityScaleZ = RBAN_SimSpaceOverride_VelocityScaleZ;