Skip to content

Gradientfall: procedural animation framework + Kern's movement pass - #5

Merged
danieltalbert merged 1 commit into
mainfrom
agent/kern-movement-pass
Jul 30, 2026
Merged

Gradientfall: procedural animation framework + Kern's movement pass#5
danieltalbert merged 1 commit into
mainfrom
agent/kern-movement-pass

Conversation

@danieltalbert

Copy link
Copy Markdown
Owner

Kern's locomotion is rebuilt on a new creature-agnostic animation stack under game/src/anim/, so every future villager, monster and boss inherits it rather than getting its own hand-tuned sine waves.

The load-bearing change

The gait cycle is phased by distance travelled, not by time:

phase += distance_this_frame / stride_length

A planted foot's body-relative position then retreats at exactly the speed the body advances, so it holds still in world space as an algebraic identity — at any speed, mid-acceleration, across gait changes. The placeholder did phase += delta * rate while the body moved at whatever speed it liked, which is why the feet skated.

Framework (9 modules)

Module Responsibility
gait_engine.gd Distance-phased cycle; rigid-foot heel/toe rocker
gait_profile.gd Gaits as biomechanics, blended continuously by speed
two_bone_ik.gd Closed-form law-of-cosines leg solve
foot_planter.gd Ground probes, leashed world plant-locks, pelvis drop
locomotion_profile.gd Measures limbs off the rig; rescales by leg length
pose_stack.gd Layered quaternion pose (euler layers do not compose)
emote_library.gd / emote_player.gd 16 emotes; blending; partial-body
anim_math.gd Half-life damping, exact critically-damped springs
creature_animator.gd Coordinator: lean, air, landing, idle life

Gaits blend continuously, so there is no walk/run threshold to pop at — duty factor slides through 0.5 and double-support becomes a flight phase the way a real gait transition does.

Kern

Analog walk/jog/run/sprint (stick deflection is the speed), crouch with capsule resize and ceiling check, slope-aware pace, step-up, landing absorption, turning that costs momentum, idle fidget scheduler, head look-at with travel anticipation, and 16 emotes/dances on a radial wheel (B / right-stick click).

Dances are named out of the world's own vocabulary: Gradient Descent, The Backprop, Overfit, Dropout, Convergence, Weight Shuffle, Epoch Step, Softmax.

Verification

New instrumented bench scenes/dev/locomotion_lab.tscn drives the real controller through 20 scripted segments on a four-zone obstacle course (flat, ramps, stairs, broken ground) via the Input singleton.

Metric Before After
Foot slip (overall) 147 mm/m 47 mm/m
Foot slip (walk) 148 mm/m 19-23 mm/m
Ground error 60 mm 7.4 mm
Backward-knee frames 8182 0
Worst pose jerk 58 rad/s 47 rad/s

Idle, hard-stop and turn-in-place measure ~0.2 mm. Game boots clean headless; validate_content.py passes 111 entries. Gait and dance frames eyes-verified against ground stripes.

Fixed in passing (both pre-existing)

  • The placeholder gait bent Kern's knees backwards at every speed — positive X on the shin is hyperextension on this rig. The IK now derives knee direction from a pole vector so it cannot recur, and the bench fails the run if it does.
  • The boot shaft stopped 65 mm below the trouser cuff, leaving a visible ring of nothing between boot and trouser whenever the knee bent.

Known limitations (documented in DEVLOG)

  • Residual slip concentrates in the heel/toe rocker at jog and above; flat-sole slip is near zero, so the plant lock itself is sound.
  • Kern's rig gives him a 0.81 m leg on a 1.78 m body (a real adult is ~0.87 m) because his ankle sits ~4 cm high. That forces a stride cap and a slightly brisk cadence. Lowering the ankle would buy it back but moves the boot meshes and the imported-rig retarget, so it is its own change.
  • NPCs and monsters are still un-skeletoned meshes; rigging them to adopt CreatureAnimator is the next milestone.

🤖 Generated with Claude Code

Kern's locomotion is rebuilt on a new creature-agnostic animation stack under
game/src/anim/, so every future villager, monster and boss inherits it rather
than getting its own hand-tuned sine waves.

The load-bearing change: the gait cycle is phased by DISTANCE TRAVELLED, not by
time. A planted foot's body-relative position then retreats at exactly the speed
the body advances, so it holds still in world space by algebraic identity rather
than by tuning. The placeholder advanced its cycle on a timer while the body
moved at whatever speed it liked, which is why the feet skated.

Framework (9 modules): distance-phased gait engine; gait profiles as
biomechanics, blended continuously by speed so there is no walk/run threshold to
pop at; closed-form two-bone IK; terrain foot planting with leashed world
plant-locks and surface-aligned ankles; a rigid-foot heel/toe rocker that keeps
the contact patch exactly still through the roll; limb measurement off the rig
itself; layered quaternion pose stack; emote library and player; coordinator.

Kern: analog walk/jog/run/sprint (stick deflection IS the speed), crouch with
capsule resize and ceiling check, slope-aware pace, step-up, landing absorption,
turning that costs momentum, idle fidgets, head look-at, and 16 emotes/dances on
a radial wheel.

Verified with a new instrumented bench (scenes/dev/locomotion_lab.tscn) driving
the real controller through 20 scripted segments on a four-zone obstacle course:
foot slip 147 -> 47 mm/m overall and 19-23 mm/m at a walk, ground error
60 -> 7.4 mm, backward-knee frames 8182 -> 0, IK shortfall 5 mm. Game boots
clean; validator passes 111 entries.

Fixed in passing, both pre-existing: the placeholder gait bent Kern's knees
BACKWARDS at every speed (positive X on the shin is hyperextension on this rig),
and the boot shaft stopped 65 mm below the trouser cuff, leaving a visible hole
whenever the knee bent.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@danieltalbert
danieltalbert merged commit 8d08f27 into main Jul 30, 2026
1 check passed
@danieltalbert
danieltalbert deleted the agent/kern-movement-pass branch July 30, 2026 21:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant