# The Walk-Cycle Playbook

**How I got an AI-drawn cartoon to walk without shrinking, sliding or moving like a robot.**

By Evan Kennedy · [evanwkennedy.com/lab/dad-hat-side-quests](https://www.evanwkennedy.com/lab/dad-hat-side-quests/) · @dadhatsidequests

Free to use, copy and adapt. If it helps you make something, I'd love to see it.

---

## Who this is for

You have a cartoon character, drawn by an image model or by you, and you want it to walk in a video. Not a one-off clip from a video model, but a walk you can reuse, that stays on-model, and that you can drop into any scene.

You'll need:

- **An image model that can edit from reference images.** I used ChatGPT's image generation, run from the Codex CLI so it could save files straight into my project. Any model that takes reference images and follows layout instructions works.
- **A coding agent.** I used Claude Code. You describe the rig, and it writes the code, runs it and measures the result.
- **A way to put frames into a video.** I used [Remotion](https://www.remotion.dev/) (video made with React), but the rig's output is plain data, so any tool that can place images works. Check Remotion's license if you use it for a company.

This took me three versions. Here's why the first two failed, so you can skip them.

---

## Why the obvious ways fail

### Attempt 1: ask the image model to draw every frame

I had the model draw the walk frame by frame: the key poses, then in-betweens, 12 drawings per step.

- **He grew and shrank.** Every drawing is a new generation, so the proportions drift. I measured the area of his eye whites across the cycle: it swung **±8 %**. On screen he pulses as he walks.
- **The spacing was wrong.** The distance between the in-betweens came out uneven (3 px in one gap, 106 px in the next), so the walk stuttered. Asking the model to fix the spacing didn't work: redrawn in-betweens overshoot.

It looks hand-drawn, but you can't fix consistency with prompts.

### Attempt 2: a rig in code

Next, the model drew only the rigid parts (head, torso, glove, shoe) once, and code drew the arms and legs as curves and moved everything with math.

- **The size was perfect,** because every part is the same drawing every frame.
- **It moved like math.** Too smooth, perfectly mirrored, no weight. The limbs were curves drawn in code, so they didn't look like the rest of the character.

### What worked: the swap rig

Combine the two. **The model draws every part once, including a library of limb poses. Code only picks, places and turns those drawings.** It never draws anything itself.

This is the cut-out and replacement-animation idea from old cartoons and stop-motion: a box of drawn mouths, hands and legs, swapped per frame.

Result: eye-white spread went from **±8.4 % to ±0.4 %**, and the limbs look hand-drawn because they are.

---

## The idea in one picture

```
draw once                         code picks + places per frame
──────────                        ─────────────────────────────
head, torso, glove, shoe   ──►    feet locked to the floor (heel, then toe)
14 leg drawings (by bend)  ──►    the leg drawing whose bend fits hip → ankle
 9 arm drawings (by bow)   ──►    the arm drawing that fits the swing speed
                                  turn + move each part (tiny stretch only)
                                  ──► walk.json: one list of image layers per frame
```

---

## Step 1: Lock the character

Get one approved drawing of your character first, and generate everything else as **edits of it** ("keep everything the same, only change …"). Fresh generations drift; edits don't drift as much.

Then make a **parts sheet** in profile: the parts that never bend, drawn once, at one scale.

Prompt template (fill in your character's details):

> Make a CUT-OUT ANIMATION PARTS SHEET for the character in the attached images. The parts will be assembled by code; the arms and legs will be drawn separately, so DO NOT draw any arms or legs.
>
> Every part is drawn in SIDE VIEW facing RIGHT, on-model and at the SAME SCALE as the attached figure. Same outline weight, same colors and shading.
>
> Layout: landscape 1536×1024, the 4 parts left to right in ONE row, each a single closed shape, separated by wide white space (nothing touching). BACKGROUND: one perfectly flat solid white (#FFFFFF), no gradient, glow, shadow, ground line, text or labels.
>
> 1. HEAD in profile, with a SHORT straight neck stub hanging down, cut off flat.
> 2. TORSO only: no arms or sleeves, an open collar on top where the neck goes in, nothing below the hem.
> 3. GLOVE (or hand) hanging straight DOWN, with an open cuff at the TOP where an arm plugs in.
> 4. SHOE in profile, toe pointing RIGHT, sole flat, a small opening on TOP where the leg plugs in.

The **openings** matter. Later, the arm goes *into* the cuff and the neck *into* the collar, which is what makes the joins read as one character instead of stickers.

## Step 2: Measure with something that doesn't change

You'll measure size constantly, so pick a feature that stays the same shape in every pose. **I used the width of his ball nose.** I first scaled by the eyes, but eyes change with every expression and blink, and that alone made him pulse ±5 %.

Every number below is "in nose widths".

## Step 3: Draw the limb library over guides

The limbs are the part that has to look hand-drawn, so the model draws them. But you control the shapes:

1. **Have code draw grey guide shapes:** a hose of fixed length, bent by a different amount in each slot. I used **14 legs** (straight to fully bent) and **9 arms** (4 bowed back, straight, 4 bowed forward).
2. **The model redraws each guide in place** as the real limb, in the character's style.

What I learned:

- **Space the drawings by bend, not by length.** A fixed-length hose bulges by about √(3/8 · c · (1 − c)) of its length at span c (span = hip-to-ankle distance ÷ leg length). That shoots up just below straight: the knee goes from flat to 15 % of the leg in one frame. So make the steps small near straight. My leg bulges: 0, 0.025, 0.05 … 0.275, 0.2875, 0.30 of the leg.
- **Make the guides thin.** The model draws limbs about 25 % thicker than the guide. My guides were 72 % width for legs and 85 % for arms. Tell it the thickness ("no thicker than the grey shape"), not the length; it keeps the length on its own.
- **Say "a normal opaque RGB picture on solid white, not a transparent background, no glow."** Without it, some sheets came back transparent with a halo.
- **Ask for 3 tries and keep the one that measures best.** All 3 were usually usable; one was always cleaner.
- **Pass your previous sheet as a style reference**, labeled "match its exact style, only the bends are new".

Prompt template (one leg sheet):

> Make a CUT-OUT ANIMATION LEG SHEET: 14 separate drawings of ONE LEG in TWO ROWS of 7 (no shoe, no foot, no body).
>
> Attached image 1 is a PROPORTION GUIDE, not a style reference: redraw each of its 14 grey shapes EXACTLY in place (same position, same length, same thickness, same curve) as his leg: a THIN rubber-hose leg, no thicker than the grey shape, in [his trousers]. The top end is cut off flat (the torso covers it); the bottom end is an open cuff (the shoe covers it). No knee joint: one smooth bent hose, bending exactly as much as the guide.
>
> STYLE: exactly the character's style in attached images 2 and 3, the same outline weight in pixels. BACKGROUND: perfectly flat solid white, nothing else. Every drawing a single closed shape, nothing touching.
>
> The image must be a normal opaque RGB picture on solid white: NOT a transparent background, no glow, no halo.

## Step 4: Build the rig

This is the part your coding agent writes. Here's what mine does, so you can describe it:

- **Cut the sheets.** Key the white background, split by connected shapes, and read anchors from the pixels: each limb's two ends, each opening's center. One scale per sheet, from its straight drawing.
- **Lock the feet.** The planted shoe pivots on its heel at heel strike and on its toe at toe-off, so it never slides. The swinging foot lifts (about a quarter of the leg), then drops low before passing the planted foot so the shoes don't stack.
- **Body.** The hip bobs with the steps, with a slight forward lean and a small head nod.
- **Pick the leg drawing.** Each frame, work out the bend the leg needs from hip to ankle, **ease that over ~11 frames**, and pick the nearest drawing, only switching when another is clearly better. Turn it rigidly to hit the ankle, then allow a tiny stretch along its length (stay within ~0.94–1.05) so the ankle lands exactly. Picking by length alone gave a 26 px knee jump every step; this brought it under 7 px.
- **Pick the arm drawing.** Arms swing opposite their leg and bow toward the motion, by swing speed. Interpolate the reach between neighboring drawings so a swap changes the bow while the wrist stays on its path.
- **Break the mirror.** The far arm bows 3 frames later and half as much. Before that, the arms mirrored each other in 22 of 36 frames.
- **Gloves flop.** They follow the arm, lean a third of the way toward it, and lag a few frames behind the swing. Leaning all the way spun them at every swap.
- **Into the openings.** Draw the shoe before the leg, the glove before the arm, then draw the cuff's front rim again on top. Same for the neck in the collar. Limbs plug in instead of sitting on top.
- **Far limbs are pre-darkened copies,** not a live filter, which halved render time. Keep whites near white or they read grey.
- **Tempo.** 18 frames per step at 30 fps read as a relaxed walk.

**Output one file**: one list of image layers per frame of the cycle (2 steps), each with the image name and a transform matrix. Your video tool only places images by it. Mine is `walk.json`, 36 frames.

## Step 5: Put it in a scene (and never moonwalk)

The rig gives you a walk that travels a fixed distance per step. Two honest ways to use it:

1. **Walk across:** move him by exactly that speed per frame across a still background.
2. **Walk in place:** keep him still and scroll the floor *and* everything at his depth at that speed (a tracking shot).

Don't do the third thing: walking in place in front of a scrolling backdrop while the floor under him stands still. That's a moonwalk, and people will see it (mine was called out immediately). It's fine for a quick demo of the walk, not when he's actually going somewhere.

**Stopping:** find the frames where both feet are on the floor (the contacts, one per step), offset the cycle so a contact lands where you want him to stop, and hold it for a few frames. To turn to camera, cut to a 3/4 standing drawing for ~4 frames, then a front-facing one.

## Step 6: Give it a face

- **A 3/4 head** turned toward the walk with eyes on the camera is the classic cartoon move. A front-facing head on a profile body looks pasted on.
- **Mouths:** have the model draw a few mouth edits of that one head (closed, mid, open, wide, round, F/V) and paste only the mouth region back onto the original, aligned on the nose. The rest of the head never changes, so talking can't change his size.
- **Lip sync:** [Rhubarb Lip Sync](https://github.com/DanielSWolf/rhubarb-lip-sync) (free, MIT) turns a voice recording plus its transcript into mouth shapes per frame. Map its shapes to your mouths.
- **Blinks:** draw eyelids in code over the eye whites (half and closed), so one pair works with every mouth.

## Step 7: Measure, don't eyeball

Have your agent write small checks and run them after every change:

| Check | What it catches | My target |
|---|---|---|
| Eye-white area across the cycle | Size drift | ≤ 1 % spread (got ±0.4 %) |
| Knee / wrist distance from its smooth path at a swap | Pops when a drawing changes | ≤ ~7 px |
| Limb stretch per frame | Rubbery or squashed limbs | 0.94–1.05 |
| How far a shoe sinks below the floor | Feet in the ground | 0 |
| Arms identical left/right | Robot mirroring | a few frames per cycle at most |

Then review as **looping side-by-side GIFs** against the previous version, same tempo and frame count. Small differences are invisible in one clip and obvious side by side.

---

## Hand this to your coding agent

A starter prompt. Attach your parts sheet, leg sheet and arm sheet:

> I'm building a "swap rig" walk cycle for my cartoon character. The attached sheets are drawn once and must never be redrawn by code: a parts sheet (profile head with neck stub, torso with an open collar, glove with an open cuff, shoe with an ankle opening), a sheet of N leg drawings from straight to fully bent, and a sheet of M arm drawings from bowed back to bowed forward, all hanging straight down on white.
>
> Write a tool that:
> 1. Keys the white background, cuts each sheet into its drawings, and measures anchors from the pixels (each limb's ends, the bulge of each limb, the center of each opening). Print a table of every limb's chord and bulge so I can check the sheet.
> 2. Builds a 2-step walk cycle at 18 frames per step: planted foot pivots on heel then toe and never slides; hip bob and slight lean; swing foot lifts then drops low before passing.
> 3. Per frame, picks the leg drawing whose bulge fits the hip-to-ankle distance (eased over ~11 frames, with a hold so it doesn't flicker), turns it rigidly and stretches it only along its length to land the ankle (print the stretch range; keep it within 0.94–1.05). Picks arms by swing speed, interpolating reach between neighbors; the far arm lags 3 frames and bows half as much.
> 4. Plugs limbs into the openings: shoe before leg, glove before arm, then the opening's front rim drawn again on top; same for the neck in the collar.
> 5. Writes the cycle as JSON (per frame: image layers back to front, each with a transform matrix) and renders a looping preview in place and walking across.
> 6. Includes a size check that measures the eye-white area on every frame and reports the spread.
>
> Measure everything you change and show me before/after loops side by side.

---

## Gotchas I hit

- The model sometimes ignores the background color you ask for. Key by shape as a fallback.
- Anti-aliased edges keep the old background's color. Un-mix the edge pixels or you get a colored fringe on dark scenes.
- Some image results come back a slightly different pixel size. Check sizes after every batch.
- Two color-key passes in a row in ffmpeg keep only the last one's alpha.
- A full-body drawing's legs may come back thicker than your rule. Measure them in nose widths and fix them in code before staging.

## The numbers from my build

| | Drawn frame by frame | Rig in code | Swap rig |
|---|---|---|---|
| Size drift (eye white) | ±8.4 % | ~0 | ±0.4 % |
| Looks hand-drawn | yes | no | yes |
| Knee pop at a swap | n/a | n/a | 26 px → 6.7 px after spacing by bend |
| Leg drawings | 12 per step, all different | 0 | 14, reused |

---

Made by Evan Kennedy. More builds in the Lab: [evanwkennedy.com/lab](https://www.evanwkennedy.com/lab/).
