TExcelTAD
Home › Game Physics & Animation › Unreal: Chaos, Character Movement and Control Rig

Unreal: Chaos, Character Movement and Control Rig

Unreal Engine 5 uses Chaos, Epic's own physics engine, for rigid bodies, queries, destruction (Geometry Collections), cloth and vehicles. Characters don't use rigid bodies at all: UCharacterMovementComponent (the "CMC") is a kinematic capsule controller with built-in network prediction. Animation runs in Animation Blueprints, with Control Rig and IK Rig for procedural motion and retargeting. The C++ here is real UE 5.x code (it doesn't run on the site); the runnable blocks model what the engine does with it. For the engine itself, see Unreal Engine 5 with C++. Remember that Unreal works in centimeters, Z-up.

Simulated components

Any UPrimitiveComponent (a static mesh, a sphere, a skeletal mesh) can simulate physics:

cpp
ACrate::ACrate()
{
    Mesh = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("Mesh"));
    RootComponent = Mesh;
    Mesh->SetSimulatePhysics(true);
    Mesh->SetMassOverrideInKg(NAME_None, 50.f, true);   // otherwise mass comes from volume x density
    Mesh->BodyInstance.bUseCCD = true;                   // the "Use CCD" checkbox
}

void ACrate::Kick(const FVector& Direction)
{
    // bVelChange = true: ignore mass, like Unity's ForceMode.VelocityChange
    Mesh->AddImpulse(Direction * 400.f, NAME_None, /*bVelChange=*/ true);
}
Concept Unreal
enable simulation SetSimulatePhysics(true)
force (every tick) AddForce(F), AddForceAtLocation(F, Loc), AddTorqueInRadians(T)
impulse (once) AddImpulse(J, BoneName, bVelChange)
velocity GetPhysicsLinearVelocity(), SetPhysicsLinearVelocity(V)
CCD BodyInstance.bUseCCD
collision filtering collision channels and profiles (Project Settings > Collision)
queries GetWorld()->LineTraceSingleByChannel, SweepSingleByChannel, OverlapMultiByChannel
cpp
FHitResult Hit;
FCollisionQueryParams Params(SCENE_QUERY_STAT(WeaponTrace), /*bTraceComplex=*/ false, this);
if (GetWorld()->LineTraceSingleByChannel(Hit, MuzzleLocation, MuzzleLocation + Aim * 10000.0, ECC_Visibility, Params))
{
    UE_LOG(LogTemp, Log, TEXT("hit %s at %s"), *GetNameSafe(Hit.GetActor()), *Hit.ImpactPoint.ToString());
}

How Unreal steps physics: substepping

Unlike Unity, Unreal's default is to step physics once per rendered frame with that frame's delta time, clamped by a maximum physics delta (Project Settings > Physics). That keeps physics in lockstep with gameplay, but a long frame means a long, less stable step. Two options in the same settings page change that:

  • Substepping splits a long frame into several smaller physics steps (with a maximum substep size and a maximum count).
  • Async physics ("Tick Physics Async") runs Chaos on its own fixed step, decoupled from the frame rate, with gameplay talking to it through async callbacks; it is what you want for deterministic, network-replicated physics.

Why substeps matter is easy to show with a stiff spring (a tight suspension, a ragdoll joint) stepped at 30 FPS. The same one second of simulation, with the frame split into 1, 2 or 4 substeps:

cpp · try it yourself
#include <iostream>
#include <iomanip>
#include <cmath>
#include <algorithm>

double simulate(int substeps) {
    const double k = 8000, m = 1, frameDt = 1.0 / 30;   // a stiff spring, 30 FPS frames
    double x = 1, v = 0, peak = 0;
    const double h = frameDt / substeps;
    for (int frame = 0; frame < 30; frame++)
        for (int s = 0; s < substeps; s++) {
            v += (-k / m * x) * h;                   // semi-implicit Euler
            x += v * h;
            peak = std::max(peak, std::fabs(x));
        }
    return peak;
}

int main() {
    std::cout << std::fixed << std::setprecision(3);
    std::cout << "spring frequency * frame dt = " << std::sqrt(8000.0) / 30 << " (stable below 2)\n";
    for (int n : {1, 2, 4}) {
        double peak = simulate(n);
        std::cout << n << " substep(s): largest |x| over one second = ";
        if (peak > 1000) std::cout << "exploded (" << std::scientific << std::setprecision(1) << peak << ")\n";
        else std::cout << peak << "\n";
        std::cout << std::fixed << std::setprecision(3);
    }
}
spring frequency * frame dt = 2.981 (stable below 2)
1 substep(s): largest |x| over one second = exploded (8.5e+24)
2 substep(s): largest |x| over one second = 1.500
4 substep(s): largest |x| over one second = 1.078

With one step per frame the spring explodes; with substeps the same spring stays bounded (the small overshoot above 1.0 is semi-implicit Euler's staggered position, and it shrinks as the steps get smaller). Semi-implicit Euler is only stable while ω·dt < 2 (Springs and Damping), and substepping is the engine's way of keeping dt small without forcing the whole game to run faster.

Character Movement Component

ACharacter comes with a capsule, a skeletal mesh and a UCharacterMovementComponent. It is the collide-and-slide controller from Collide and Slide plus Slopes, Steps and Ground Snapping, with movement modes (MOVE_Walking, MOVE_Falling, MOVE_Swimming, MOVE_Flying, MOVE_Custom) and client-side prediction with server correction already built in.

cpp
AHeroCharacter::AHeroCharacter()
{
    UCharacterMovementComponent* Move = GetCharacterMovement();
    Move->MaxWalkSpeed = 500.f;              // cm/s
    Move->JumpZVelocity = 600.f;             // cm/s, upward speed at takeoff
    Move->GravityScale = 1.5f;               // snappier jumps
    Move->AirControl = 0.35f;
    Move->MaxStepHeight = 40.f;              // cm
    Move->SetWalkableFloorAngle(50.f);       // degrees; also updates the walkable floor Z
    Move->bOrientRotationToMovement = true;
    bUseControllerRotationYaw = false;
}

Designers tune jumps in "how high", while the CMC wants a takeoff speed. The conversion is the projectile formula h = v² / (2g), with gravity in cm/s² scaled by GravityScale; and the walkable angle is stored as the minimum Z of a floor normal (cos(angle)):

cpp · try it yourself
#include <iostream>
#include <iomanip>
#include <cmath>

int main() {
    std::cout << std::fixed << std::setprecision(3);
    const double g = 980.0;                          // cm/s^2, Unreal's default world gravity
    for (double scale : {1.0, 1.5, 2.0}) {
        double wantHeight = 120.0;                   // cm
        double jumpZ = std::sqrt(2 * g * scale * wantHeight);
        std::cout << "GravityScale " << scale << ": JumpZVelocity " << jumpZ
                  << " cm/s for a 120 cm jump, airtime " << 2 * jumpZ / (g * scale) << " s\n";
    }
    const double pi = 3.141592653589793;
    double walkableZ = std::cos(50.0 * pi / 180);
    std::cout << "walkable floor Z for 50 deg: " << walkableZ << "\n";
    for (double slope : {30.0, 49.0, 55.0}) {
        double normalZ = std::cos(slope * pi / 180);
        std::cout << "  slope " << slope << " deg (normal Z " << normalZ << "): "
                  << (normalZ >= walkableZ ? "walkable" : "slides off") << "\n";
    }
}
GravityScale 1.000: JumpZVelocity 484.974 cm/s for a 120 cm jump, airtime 0.990 s
GravityScale 1.500: JumpZVelocity 593.970 cm/s for a 120 cm jump, airtime 0.808 s
GravityScale 2.000: JumpZVelocity 685.857 cm/s for a 120 cm jump, airtime 0.700 s
walkable floor Z for 50 deg: 0.643
  slope 30.000 deg (normal Z 0.866): walkable
  slope 49.000 deg (normal Z 0.656): walkable
  slope 55.000 deg (normal Z 0.574): slides off

Higher gravity with a higher takeoff speed gives the same peak with less hang time, which is why "floaty jump" fixes usually raise GravityScale rather than lowering JumpZVelocity.

Animation: AnimBP, Control Rig, IK Rig

An Animation Blueprint has an EventGraph (or a C++ UAnimInstance) that reads gameplay state, and an AnimGraph that turns it into a pose: state machines, Blend Spaces (blend trees), layered blends and IK nodes.

cpp
void UHeroAnimInstance::NativeUpdateAnimation(float DeltaSeconds)
{
    Super::NativeUpdateAnimation(DeltaSeconds);
    if (const APawn* Pawn = TryGetPawnOwner())
    {
        GroundSpeed = Pawn->GetVelocity().Size2D();           // drives a 1D Blend Space
        bIsFalling = Pawn->GetMovementComponent()->IsFalling();
    }
}
Course concept Unreal
blend tree Blend Space (1D, 2D)
state machine AnimGraph State Machine
two-bone IK Two Bone IK node in the AnimGraph, or IK in Control Rig
full-body / chain IK Control Rig (Full Body IK, FABRIK and CCDIK nodes)
retargeting IK Rig (chains and goals per skeleton) + IK Retargeter
animation events Anim Notifies and Notify States
root motion root motion in Montages or all animations (AnimBP class setting); the CMC consumes it
ragdoll Physics Asset + GetMesh()->SetSimulatePhysics(true) (often with the "Ragdoll" collision profile)

Control Rig is a node graph that runs at animation time, so it covers both authoring (rigging in the editor) and runtime procedural motion: foot placement, aiming, recoil. IK Rig describes a skeleton as chains and goals so the IK Retargeter can copy animation between characters of different proportions.

Tip: Use the Chaos Visual Debugger to record a physics session and scrub it frame by frame, and the show collision console command to draw collision shapes in the viewport.

Test yourself

By default, how does Unreal step physics compared with Unity?

  1. Exactly like Unity, with a fixed 0.02 s step
  2. Once per rendered frame with that frame's (clamped) delta; substepping or async physics change that
  3. Only when an actor asks
  4. Twice per frame

A designer wants a 120 cm jump with GravityScale = 2. Which formula gives JumpZVelocity?

  1. 120 * 980 * 2
  2. sqrt(2 * 980 * 2 * 120)
  3. 120 / (980 * 2)
  4. 980 * 2 / 120

Which Unreal tools retarget an animation from one skeleton to another with different proportions?

  1. Physics Asset and Chaos
  2. IK Rig and IK Retargeter
  3. Blend Space and Montage
  4. Anim Notifies