Communitygithub.com

character-state-animation

Guidelines for building expressive, state-driven interactive character animations (3D WebGL/Three.js/R3F or 2D vector/canvas) where one unified character connects smoothly across continuous loops and one-shot emotes. Use when designing, animating, shading, or polishing a mascot, companion, avatar, or stateful UI character.

What is character-state-animation?

character-state-animation is a Claude Code agent skill that guidelines for building expressive, state-driven interactive character animations (3D WebGL/Three.js/R3F or 2D vector/canvas) where one unified character connects smoothly across continuous loops and one-shot emotes. Use when designing, animating, shading, or polishing a mascot, companion, avatar, or stateful UI character.

Works with~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/ivanbayuf/character-state-animation-skill/tree/HEAD

Ask in your favorite AI

Open a new chat with this agent skill pre-loaded.

Documentation

Character State Animation Guidelines

Use these guidelines whenever building or refining an interactive character with multiple emotional or functional states. Focus on one persistent character rig whose pose, perspective, shading, and minimal VFX connect seamlessly across every state.


1. Unified State Machine Architecture

  1. One Rig, Many States: Never swap disconnected pre-baked clips that jump-cut on input. Drive a single persistent rig from a live interpolated state struct (root position, base rotation, head rotation, limb/puff scales, material palette, facial parameters, and VFX weights).
  2. Continuous vs. One-Shot States:
    • Continuous (loop): States like floating, breathing, inhale, exhale, listening, thinking, and sleepy run indefinitely until another state is selected.
    • Action / Emotes (oneshot): States like courage, hugging, smiling, sad, and speaking play a complete choreographed arc (~2.8–3.2s) and automatically transition back to the resting idle state (floating).
  3. Interruption-Safe Blending:
    • Never reset transforms or timers to rest poses when switching mid-animation. Always damp/interpolate from the current in-flight frame values into the new state's target.
    • Normalize multi-turn spin angles (±2π wrap) upon exiting spin states so the character takes the shortest angular path back to rest instead of unwinding backward.

2. Timing, Easing & Cycle Endpoints

  1. Fast Exponential Attack (expOut):
    • Avoid slow linear or symmetric smoothstep entrances that make state clicks feel sluggish or static.
    • Use an exponential ease-out curve (1 - 2^(-9t)) so poses reach ~90% within 120–200ms, paired with responsive frame damping (1 - exp(-18 * dt) for body, 1 - exp(-24 * dt) for face, 1 - exp(-14 * dt) for color).
  2. Clear opacity: 0 Cycle Endpoints:
    • Directional cyclic indicators (such as inward inhale arrows or outward exhale breath clouds) must not wrap abruptly from 1 → 0 → 1 or get bridged by laggy smoothing across cycle boundaries.
    • Reserve the final 25–30% of each cycle as a true opacity: 0 endpoint pause so the indicator reaches its destination, fades completely to 0, and rests briefly before the next cycle begins.
  3. Secondary Puff/Hand Expansion on Breathing:
    • During calm breathing loops, expand and contract the hands and side puffs/bubbles around the body (~0.94× exhale to ~1.22× inhale) rather than uniformly scaling the central head/torso dome—this reads as organic plush breathing rather than camera zoom.

3. 3D Perspective & Head-to-Body Hierarchy

  1. Upward-Tilted 3/4 Baseline & Decoupled Head Rotation:
    • Establish an appealing slightly upward-tilted 3/4 baseline (headRotX ~ -0.16, headRotY ~ +0.44, subtle +Z roll) with fuller, expressive oval eyes positioned slightly above the equator.
    • Apply 100% of expressive state yaw and pitch to the head, while letting the body/base follow at only ~30–35%. Rotating the 3D head independently shifts and foreshortens the eyes naturally across states without scrambling the base silhouette.
  2. Alive Idle Perspective:
    • Keep the resting idle state dynamic rather than locked to one angle: alternate smoothly between a 3/4 resting gaze and periodic front-facing perk-ups (subtle eye specular glint + micro-smile), punctuated by quick natural blinks (~140ms).
  3. Clean Minimal Facial Shapes:
    • Render open mouths (smiling, courage, speaking) as clean, borderless single shapes (clipped tongue or upper teeth bar) with zero extra outline rings.
    • Prefer clean graphic closed-eye strokes (^ ^ happy crescents, u u calm arcs, / \ sleepy slants) over flat 2D eyelid patches that clash with 3D surface shading.

4. Limb Sculpting & Physical Contact Layering

  1. Crease-Free, Thumb-Free Curved Limbs (C / J Mittens):
    • Sculpt soft front hands/paws as smooth C or J arcs rather than plain spheres or pinched multi-bump blobs.
    • Keep the spine's radius of curvature strictly larger than the cross-section radius (R_arc > max(ringR)) and use a single continuous capsule-hemisphere profile (pow(sin(t), 0.56) over t ∈ [0, π]) rather than piecewise cap joints—eliminating both inner-bend creases and middle "thumb" peaks.
    • Place hands forward (+Z) clear of the torso sphere so the body never slices a notch into the upper hand edge, and rotate the outer shoulder joints slightly backward (-Z) so shoulders nestle into the body.
  2. Tight Physical Hugs (3-Layer Z Clearance & V-Squish):
    • Maintain strict 3-layer depth ordering: z_body_chest < z_prop < z_hands (tilting the prop parallel to the chest slope so the bulging upper torso never clips the top of the prop, while the hands wrap cleanly across its lower front).
    • Keep a crisp V-cleft and V-tapered silhouette on hugged hearts even under squeeze deformation: accentuate the center V dip and side V taper as the hands press inward, paired with volume-preserving upward/forward bulge synced to squeeze pulses, positioned cleanly below the smile.

5. Soft Plush Shading, Rim Light & Silhouette Glow

  1. 360° Fresnel Rim Light:
    • Inject a view-space Fresnel rim pass (pow(1 - clamp(dot(N, V), 0, 1), 2.3) + crisp 4.5 edge) so overlapping puffs, limbs, and shadowed contours always separate cleanly from each other and dark backgrounds.
  2. Clean Color Transitions (Avoid White Blowout & Muddy Midtones):
    • Keep key light intensity calibrated so pastel base albedos (e.g., light lavender) stay visibly tinted rather than clipping to pure white.
    • When pairing cool purple/periwinkle shadows with warm creamy-yellow highlights, bridge midtones through warm pastel pink/rose and mix() into the highlight color (additive yellow over purple desaturates midtones into muddy beige/grey).
    • For sad states, use a low-saturation grayish dark-purple rather than flat neutral grey or vivid neon purple.
  3. Silhouette-Hugging Soft Glow:
    • Add a subtle luminous outer glow across all states that hugs the character's exact alpha contour (e.g., state-tinted drop-shadow on an alpha-transparent canvas), keeping internal eyes and shading razor-sharp while avoiding hard circular backdrop sprites.

6. Disciplined VFX

  1. Hero Motion Over Particle Clutter:
    • Favor one readable hero element (e.g., a single 3D golden star orbiting on a tilted plane with a camera-facing tapering comet trail, paired with an expressive 360° character spin) over dozens of distracting glitter particles.
    • Keep breathing and smiling glows anchored in the character's own subsurface radiance and silhouette bloom rather than adding glitter or circular halo rings.
  2. Seamless Translucent Volumes:
    • When constructing scalloped multi-sphere translucent puffs (such as a 3-lobed exhale mini-cloud), combine a depth-only pre-pass (colorWrite: false, depthWrite: true), a hardware stencil single-draw guard (NotEqualStencilFunc + ReplaceStencilOp), and a group-space gradient (instead of per-sphere Fresnel rims) so zero internal intersecting rings appear.

Related Skills