Inverse Kinematics

Move the hand. The arm follows.

IK solvers adjust bone rotations so an end effector (hand, foot, tentacle tip) reaches a target position. Three solver types cover everything from simple arms to complex chains.


How it works

Define a chain of bones (nodes) from root to tip. Set a target position. The IK solver computes the rotation of each bone so the tip reaches the target.

Hip ──── Thigh ──── Shin ──── Foot
(root) (tip → target)

The solver adjusts thigh and shin rotations. The foot reaches the target. The hip stays fixed.


Three solvers

Two-bone (analytical)

Covers 90% of 2D cases. Arms and legs — exactly two bones between root and tip.

Uses the law of cosines to compute both joint angles directly. No iteration — one frame of math gives the exact answer.

Shoulder ──── Upper Arm ──── Forearm ──── Hand (→ target)

CCD (Cyclic Coordinate Descent)

Iterative solver for any chain length. Each iteration rotates one joint to point its subtree toward the target. Converges in 5-15 iterations.

Best for: tails, tentacles, waving arms, chains with many segments.

FABRIK (Forward And Backward Reaching IK)

Iterative, position-based. Alternates forward and backward passes along the chain. Handles constraints better than CCD.

Best for: spines, ropes, organic motion, chains where joint limits matter.


Joint constraints

Each joint has rotation limits:

Knee: minAngle: -5, maxAngle: 150 ← bends forward, barely backward
Elbow: minAngle: 0, maxAngle: 145 ← bends one direction only
Spine: minAngle: -30, maxAngle: 30 ← limited flex
Tentacle: minAngle: -180, maxAngle: 180 ← full rotation

Constraints prevent unnatural poses. A knee that bends backward looks wrong — constraints fix it.

preferredAngle biases the solver when multiple solutions exist. Set the knee's preferred angle to 90 — it bends forward, not sideways.


IK weight

Weight blends between the keyframed pose and the IK-solved pose:

WeightResult
0Pure keyframe animation — IK ignored
0.5Halfway between keyframed and IK pose
1Full IK — end effector reaches target

Weight is animatable. Keyframe it for transitions:

t=0.0: ikWeight = 0 ← walking, feet follow keyframes
t=0.3: ikWeight = 1 ← feet lock to terrain targets
Jump: ikWeight = 0 ← feet release during jump

title: "IK arm reaching"
description: "An arm that reaches toward the mouse cursor"
nodes:
  - type: RECT, name: "UpperArm", x: 150, y: 200, w: 80, h: 12, fill: "#3498DB"
  - type: RECT, name: "Forearm", x: 230, y: 200, w: 80, h: 10, fill: "#2980B9"
  - type: ELLIPSE, name: "Hand", x: 310, y: 200, w: 16, h: 16, fill: "#E74C3C"
  - type: ELLIPSE, name: "Target", w: 10, h: 10, fill: "#F39C12"
formulas:
  - node: "Target", prop: "x", value: "mouse.x"
  - node: "Target", prop: "y", value: "mouse.y"
ik_chains:
  - bones: ["UpperArm", "Forearm", "Hand"], target: "Target", solver: "twoBone"
tools_visible: [select, play]
ui_visible: [properties, formulas]

Pipeline position

IK runs after animation blending, before applying to real nodes:

1. Animation clips evaluate → mock has keyframed rotations
2. IK chains solve → adjust mock rotations to reach targets
3. Apply final mock to real nodes → render

This order means animation sets the base pose, IK refines it. Walk animation moves legs, IK adjusts feet to match terrain.


Pole targets

For two-bone IK, a pole target sets the bend direction. Without it, the knee could bend sideways.

Place a pole target node in front of the knee — the solver bends toward it. Place it behind — it bends backward.

Target: foot position (where the foot goes)
Pole: knee direction (which way the knee points)


Chain definition

IK Chain:
bones: ["hip", "thigh", "shin", "foot"] ← root to tip
target: "footTarget" ← node to reach
pole: "kneeDirection" ← bend hint (optional)
solver: "twoBone" ← solver type
weight: 1.0 ← IK influence
constraints:
thigh: { min: -15, max: 90 }
shin: { min: 0, max: 150 }


Canvas overlay

IK chains show visual feedback in the editor:

  • Dotted line from root to tip bone
  • Target point — draggable circle (or bound to a slot node)
  • Pole target — diamond indicator for bend direction
  • Joint constraints — arc wedges showing allowed rotation range per bone
  • Weight slider — in the properties panel

Back to animationBlendingTimeline

← НазадTimelineДальше →Animation Blending