Skip to main content

External Force Presets

Version Info

Added in v1.16.0

The External Force preset system allows you to apply various external forces in a modular way. Multiple presets are available that inherit from the base struct, and you can also add custom presets in C++.

Overview

External Force Preset System

Types of presets and application flow

Architecture

FKawaiiPhysics_ExternalForce (Base)
├─ FKawaiiPhysics_ExternalForce_Basic (Generic directional force)
├─ FKawaiiPhysics_ExternalForce_Curve (Time-based curve force)
├─ FKawaiiPhysics_ExternalForce_Gravity (Gravity)
└─ FKawaiiPhysics_ExternalForce_Wind (Wind)

View Source

Base Class: FKawaiiPhysics_ExternalForce

The base struct for all external force presets.

Common Parameters

ParameterTypeDefaultDescription
bIsEnabledbooltrueEnable/disable the force
bDrawDebugboolfalseEnable/disable debug drawing
ApplyBoneFilterTArray<FBoneReference>EmptyBones to apply force to (all if empty)
IgnoreBoneFilterTArray<FBoneReference>EmptyBones to exclude from force
ExternalForceSpaceEExternalForceSpaceWorldSpaceSimulation space
RandomForceScaleRangeFFloatInterval(1.0, 1.0)Random scale range for force

Simulation Space (EExternalForceSpace)

ValueDescription
ComponentSpaceSimulate in component space. Mesh movement doesn't affect velocity
WorldSpaceSimulate in world space. Mesh movement affects velocity
BoneSpaceSimulate in another bone's space

Bone Filter Usage Example

// Apply force only to specific bones
ApplyBoneFilter.Add(FBoneReference("hair_01"));
ApplyBoneFilter.Add(FBoneReference("hair_02"));

// Exclude specific bones
IgnoreBoneFilter.Add(FBoneReference("hair_root"));

Basic: Simple Directional Force

Applies a constant directional force continuously or at intervals.

Parameters

ParameterTypeDefaultDescription
ForceDirFVector(0, 0, 0)Force direction
ForceRateByBoneLengthRateFRuntimeFloatCurve-Force correction curve by bone length ratio
Intervalfloat0.0Interval between force applications (seconds). 0 = every frame

Usage Example

// Constant force to the right
FKawaiiPhysics_ExternalForce_Basic BasicForce;
BasicForce.ForceDir = FVector(100, 0, 0);
BasicForce.Interval = 0.0f; // Apply every frame

Curve: Curve-Based Force

External force that changes over time according to a curve. Ideal for animation and timeline-based effects.

Parameters

ParameterTypeDefaultDescription
ForceCurveFRuntimeVectorCurve-Force curve over time (X: time, Y: force)
CurveEvaluateTypeEExternalForceCurveEvaluateTypeSingleCurve evaluation method
SubstepCountint10Number of time subdivisions (for non-Single modes)
TimeScalefloat1.0Time scale factor
ForceRateByBoneLengthRateFRuntimeFloatCurve-Force correction curve by bone length ratio

Curve Evaluation Type (EExternalForceCurveEvaluateType)

ValueDescription
SingleEvaluate at a single point
AverageAverage of multiple points
MaxMaximum of multiple points
MinMinimum of multiple points

Usage Example

// Oscillating force
FKawaiiPhysics_ExternalForce_Curve CurveForce;
CurveForce.TimeScale = 2.0f; // Play at 2x speed
CurveForce.CurveEvaluateType = EExternalForceCurveEvaluateType::Average;

Gravity: Gravity Force

Simulates gravity. Can integrate with Character settings.

note

Gravity is always fixed to WorldSpace. Space selection is not available.

Parameters

ParameterTypeDefaultDescription
ForceRateByBoneLengthRateFRuntimeFloatCurve-Force correction curve by bone length ratio
bUseCharacterGravityDirectionboolfalseUse Character's CustomGravityDirection (UE5.4+)
bUseCharacterGravityScaleboolfalseUse Character's GravityScale
bUseOverrideGravityDirectionboolfalseWhether to override gravity direction
OverrideGravityDirectionFVector(0, 0, 0)Override gravity direction value

Integration with Character

In UE5.4 and later, you can automatically integrate with Character's gravity settings.

// Use Character's gravity settings
FKawaiiPhysics_ExternalForce_Gravity GravityForce;
GravityForce.bUseCharacterGravityDirection = true;
GravityForce.bUseCharacterGravityScale = true;

Overriding Gravity Direction

// Horizontal gravity (e.g., space station)
FKawaiiPhysics_ExternalForce_Gravity GravityForce;
GravityForce.bUseOverrideGravityDirection = true;
GravityForce.OverrideGravityDirection = FVector(1, 0, 0);

Wind: Wind Force

Uses wind from WindDirectionalSource. Designed to work with Cloth and SpeedTree.

note

Wind is always fixed to WorldSpace. Space selection is not available.

Parameters

ParameterTypeDefaultDescription
ForceRateByBoneLengthRateFRuntimeFloatCurve-Force correction curve by bone length ratio
WindDirectionNoiseAnglefloat0.0Noise angle for wind direction from WindDirectionalSource (degrees)

WindDirectionalSource Setup

  1. Place a WindDirectionalSource in the level
  2. Configure wind strength and direction
  3. Add Wind preset to KawaiiPhysics node
FKawaiiPhysics_ExternalForce_Wind WindForce;
WindForce.WindDirectionNoiseAngle = 15.0f; // 15 degree random variation

Custom External Forces (CustomExternalForces)

Experimental Feature

This feature is experimental. It may not work properly unless you click on the AnimNode or compile the Animation Blueprint.

You can implement custom force logic in Blueprint or C++.

Base Class: UKawaiiPhysics_CustomExternalForce

UCLASS(Abstract, Blueprintable, EditInlineNew, CollapseCategories)
class UKawaiiPhysics_CustomExternalForce : public UObject

Parameters

ParameterTypeDefaultDescription
bIsEnabledbooltrueWhether this custom force is enabled
bDrawDebugboolfalseWhether to draw debug visualization

Overridable Functions

FunctionDescription
PreApplyPre-apply processing (called once for all bones)
ApplyApply force to each bone (called per bone)

C++ Implementation Example

UCLASS()
class UMyCustomForce : public UKawaiiPhysics_CustomExternalForce
{
GENERATED_BODY()

public:
virtual void Apply_Implementation(FAnimNode_KawaiiPhysics& Node,
int32 ModifyBoneIndex, const USkeletalMeshComponent* SkelComp,
const FTransform& BoneTransform) override
{
// Custom logic
}
};

Blueprint Implementation

  1. Create a Blueprint class inheriting from UKawaiiPhysics_CustomExternalForce
  2. Override PreApply and Apply events
  3. Add to KawaiiPhysics node's CustomExternalForces

Common Features

ForceRateByBoneLengthRate

A force correction curve based on distance from root, available in all presets.

  • X-axis: Position in bone chain (0.0 = root, 1.0 = tip)
  • Y-axis: Force scale factor
// Example: Increase force toward the tip
ForceRateByBoneLengthRate.GetRichCurve()->AddKey(0.0f, 0.5f);
ForceRateByBoneLengthRate.GetRichCurve()->AddKey(1.0f, 1.5f);

Debug Drawing

Set bDrawDebug = true to visualize force vectors in the viewport.


Blueprint API

External forces can be dynamically controlled from Blueprint.

Adding External Force

UFUNCTION(BlueprintCallable, Category = "Kawaii Physics")
static bool AddExternalForce(const FKawaiiPhysicsReference& KawaiiPhysics,
FInstancedStruct& ExternalForce, UObject* Owner, bool bIsOneShot = false);

Adding External Forces to Component

UFUNCTION(BlueprintCallable, Category = "Kawaii Physics")
static bool AddExternalForcesToComponent(USkeletalMeshComponent* MeshComp,
TArray<FInstancedStruct>& ExternalForces, UObject* Owner,
FGameplayTagContainer& FilterTags,
bool bFilterExactMatch = false,
bool bIsOneShot = false);

For more details, see UKawaiiPhysicsLibrary.