Strata - v1.4.10
    Preparing search index...

    Class ProceduralGait

    Procedural Locomotion and Gait System.

    Generates natural walking, running, and movement animations without keyframes. Automatically calculates foot placement, step timing, and body motion based on character velocity and direction.

    Features:

    • Adaptive step length based on movement speed
    • Natural body bob and sway
    • Hip rotation for realistic weight transfer
    • Configurable gait types (walk, run, sneak, limp, etc.)
    • Foot lifting phases for smooth animation

    Use Cases:

    • Bipedal character locomotion
    • Quadruped or multi-legged creatures (use multiple instances)
    • NPCs that walk procedurally
    • Adaptive animation for varied terrain
    // Basic walking character
    const gait = new ProceduralGait({
    stepLength: 0.8, // How far each step reaches
    stepHeight: 0.15, // How high feet lift
    stepDuration: 0.4, // Time per step (seconds)
    bodyBob: 0.05, // Vertical body bounce
    bodySwayAmplitude: 0.02, // Side-to-side sway
    hipRotation: 0.1, // Hip twist during walk
    phaseOffset: 0.5, // Left/right foot timing (0.5 = alternating)
    footOvershoot: 0.1 // Foot lands slightly ahead
    });

    // In update loop
    function animate(deltaTime: number) {
    const bodyPos = character.position;
    const forward = character.getWorldDirection(new THREE.Vector3());
    const velocity = character.velocity;

    const state = gait.update(bodyPos, forward, velocity, deltaTime);

    // Position feet
    leftFoot.position.copy(state.leftFootTarget);
    rightFoot.position.copy(state.rightFootTarget);

    // Apply body motion
    character.position.add(state.bodyOffset);
    character.rotation.setFromEuler(state.bodyRotation);

    // Check for footstep events
    if (state.leftFootLifted) {
    playFootstepSound();
    }
    }
    // Running gait - faster, longer strides
    const runGait = new ProceduralGait({
    stepLength: 1.5, // Long strides
    stepHeight: 0.25, // Higher lift
    stepDuration: 0.3, // Quick steps
    bodyBob: 0.08, // More bounce
    bodySwayAmplitude: 0.01, // Less sway
    hipRotation: 0.12,
    phaseOffset: 0.5,
    footOvershoot: 0.15
    });
    // Sneaking gait - slow, careful steps
    const sneakGait = new ProceduralGait({
    stepLength: 0.4, // Short steps
    stepHeight: 0.05, // Barely lift feet
    stepDuration: 0.8, // Slow steps
    bodyBob: 0.01, // Minimal bounce
    bodySwayAmplitude: 0.005,
    hipRotation: 0.03,
    phaseOffset: 0.5,
    footOvershoot: 0.02
    });
    Index

    Constructors

    Methods

    • Parameters

      • bodyPosition: Vector3
      • bodyForward: Vector3
      • velocity: Vector3
      • deltaTime: number

      Returns GaitState