Skip to main content
skill CX Codex

unity-animation — Claude Code skill: Unity Animator, Mecanim

Guides the agent through Animator Controllers in Unity 6.3 LTS: parameters, transitions, blend trees, layers, humanoid IK. Useful when one state machine has to cover walking, jumping and aiming.

Install into Claude Code · Skills CLI (Vercel) All methods and platforms ↓
npx skills add gamedev-skills/awesome-gamedev-agent-skills --skill unity-animation -a claude-code
Open on GitHub

What unity-animation does

This skill fixes the order of work on Animator Controllers in Unity 6.3 LTS (6000.3): states, transitions, parameters, blend trees, layers, humanoid IK. Attach an Animator, declare Float, Bool, Int and Trigger parameters, then drive them from script with SetFloat, SetBool, SetTrigger. Code pokes parameters, never states — the state machine resolves transitions on its own.

Samples cover hash caching with Animator.StringToHash, dampTime smoothing for analog input, CrossFade against CrossFadeInFixedTime, and waiting out a state with GetNextAnimatorStateInfo. A companion file references/blend-trees-and-ik.md goes into 1D and 2D Freeform blend trees, Avatar Masks and OnAnimatorIK.

You need a Unity 6.3 LTS project. The trap worth knowing first: with Apply Root Motion on, scripted movement on the transform fights the clip, so the character slides or stalls. Pick one. IK stays silent without a Humanoid Avatar and IK Pass enabled on the layer.

What it helps with

  • wire idle → walk → run into a single blend tree
  • push planar speed from script as a float parameter
  • layer an upper-body aim animation over locomotion
  • attach foot IK on a humanoid rig
  • trace why a transition waits before firing

Example prompts for the agent

  • Wire the Animator: Speed goes through SetFloat and drives the idle/walk/run blend tree
  • Jump fires late — check Has Exit Time on the transition in the .controller
  • Add left-hand IK inside OnAnimatorIK and turn on IK Pass for the layer

How to install unity-animation

1Skills CLI (Vercel)

npx skills add gamedev-skills/awesome-gamedev-agent-skills --skill unity-animation -a claude-code

2Manually: put the files in place

~/.claude/skills/unity-animation/SKILL.md

Copy the whole skill folder; for one project use .claude/skills/unity-animation/

Step by step, with commands for each platform: How to install skills in Claude Code: five ways

Questions about unity-animation

How do I install unity-animation in Claude Code?

Run npx skills add gamedev-skills/awesome-gamedev-agent-skills --skill unity-animation -a claude-code. The skill lands at ~/.claude/skills/unity-animation/SKILL.md.

What does unity-animation do?

It tells the agent how to wire clips into a state machine and drive them from C#: parameters, blend trees, layers with Avatar Masks, IK. It also lists the usual breakage, such as parameter name typos that fail without a word.

Does IK work on a non-humanoid rig?

No. IK applies only inside OnAnimatorIK, needs IK Pass enabled on the layer, and requires a Humanoid Avatar on the model.

Source text

SKILL.md · Apache-2.0
---
name: unity-animation
description: >
  Drive Unity 6.3 LTS character animation with Animator Controllers: states, transitions,
  parameters, blend trees, animation layers, and humanoid Avatar IK. Use when wiring an
  Animator, setting parameters from script (SetFloat/SetBool/SetTrigger), building blend
  trees, or when the user mentions Animator, Mecanim, state machine, blend tree, or .controller.
---

# Unity Animation (Animator / Mecanim)

Control animation state with Unity 6.3 LTS's `Animator` and Animator Controllers: parameters,
transitions, blend trees, layers, and humanoid IK. Targets **Unity 6.3 LTS (6000.3)**.

## When to use

- Use when connecting animation clips into a state machine, driving them from script via
  parameters, blending locomotion (idle→walk→run), layering an upper-body action over
  movement, or adding foot/hand IK on a humanoid rig.
- Use when the project has `*.controller` (Animator Controller) and `*.anim` assets, or a
  rigged model with an Avatar.

**When *not* to use:** simple non-skeletal value tweens (UI fades, position lerps) are better
done with a tween/coroutine — see `unity-csharp-scripting`. Timeline cutscenes are a separate
tool. 2D sprite frame animation also uses the Animator but with sprite keyframes.

## Core workflow

1. **Add an `Animator`** to the model and assign an Animator Controller; for a humanoid model,
   set its rig to **Humanoid** so it has an Avatar (enables retargeting and IK).
2. **Define parameters** on the controller — `Float` (Speed), `Bool` (IsGrounded), `Int`,
   `Trigger` (Jump) — and states with transitions whose *conditions* read those parameters.
3. **Set parameters from script**, never poke states directly: `SetFloat`, `SetBool`,
   `SetInteger`, `SetTrigger`. The state machine resolves transitions for you.
4. **Blend continuous motion with a Blend Tree** (one `Float` like Speed drives idle↔walk↔run)
   instead of many discrete states + transitions.
5. **Layer additive/override motion** (e.g. an upper-body "aim" layer with an Avatar Mask) and
   control its `layerWeight`.
6. **Verify** in the Animator window during Play mode — the live state highlights and parameter
   values update, so you can see exactly which transition fired (or didn't).

## Patterns

### 1. Drive locomotion + a one-shot action from script

```csharp
using UnityEngine;

[RequireComponent(typeof(Animator))]
public class CharacterAnim : MonoBehaviour
{
    private Animator _anim;
    // Cache parameter hashes — faster and typo-proof vs string lookups every frame.
    private static readonly int Speed     = Animator.StringToHash("Speed");
    private static readonly int IsGrounded= Animator.StringToHash("IsGrounded");
    private static readonly int Jump      = Animator.StringToHash("Jump");

    private void Awake() => _anim = GetComponent<Animator>();

    public void Tick(float planarSpeed, bool grounded)
    {
        _anim.SetFloat(Speed, planarSpeed);     // drives a 1D blend tree (idle/walk/run)
        _anim.SetBool(IsGrounded, grounded);    // gates a falling/landing transition
    }

    public void DoJump() => _anim.SetTrigger(Jump);  // fire-and-forget; auto-resets after use
}
```

### 2. Smooth a noisy input into a blend parameter

```csharp
// dampTime smooths Speed so the blend tree doesn't snap; great for analog sticks.
_anim.SetFloat(Speed, targetSpeed, 0.1f /* dampTime */, Time.deltaTime);
```

### 3. Play / cross-fade a state directly (bypassing parameter conditions)

```csharp
// Useful for hit reactions where you want an immediate, explicit transition.
_anim.CrossFade("Hit", 0.1f);                    // 0.1 = 10% of the state's length, not seconds
_anim.CrossFadeInFixedTime("Hit", 0.15f);        // duration in seconds
// Or jump instantly:  _anim.Play("Hit");
```

### 4. Wait until the current state finishes

```csharp
private System.Collections.IEnumerator AfterAttack()
{
    yield return null;                                 // let the Animator start the transition
    // During a transition the "current" state is the one being left; read the next one.
    var info = _anim.IsInTransition(0)
        ? _anim.GetNextAnimatorStateInfo(0)
        : _anim.GetCurrentAnimatorStateInfo(0);        // layer 0
    yield return new WaitForSeconds(info.length);      // seconds; approximate, varies in blend trees
    // ...follow-up logic
}
```

## Pitfalls

- **`SetTrigger` missed or "sticks"** — triggers are consumed by the next satisfied transition
  and auto-reset; if no transition consumes it, it can fire later unexpectedly. Use
  `ResetTrigger` to clear, or prefer a `Bool` when the condition is a sustained state.
- **String parameter typos fail silently** — a misspelled name just does nothing. Use
  `Animator.StringToHash` and cache the int hashes.
- **Transition feels laggy** — `Has Exit Time` makes the transition wait for the clip to reach
  a normalized time. Uncheck it for responsive, condition-driven transitions (jump, hit).
- **Character slides or won't move** — `Apply Root Motion` is on but your code also moves the
  transform (or vice versa). Decide: root motion *or* scripted movement, not both.
- **Upper-body layer overrides the whole body** — set the layer's Blend mode (Override vs
  Additive), assign an Avatar Mask, and tune `layerWeight` (0–1).
- **A cross-fade is much slower or faster than expected** — `CrossFade`'s duration is
  *normalized* to the state's length. Use `CrossFadeInFixedTime` to give the
  duration in seconds.
- **IK does nothing** — IK only applies inside `OnAnimatorIK`, requires "IK Pass" enabled on
  the layer, and needs a Humanoid Avatar.

## References

- For **blend trees** (1D vs 2D Freeform/Directional), **animation layers + Avatar Masks**,
  and **humanoid IK** (`OnAnimatorIK`, `SetIKPositionWeight`, `SetIKPosition`, look-at), read
  `references/blend-trees-and-ik.md`.
- Primary docs: Unity Manual "Animation" section and `ScriptReference/Animator`.

## Related skills

- `unity-csharp-scripting` — the MonoBehaviour and coroutine timing used above.
- `unity-physics` — moving the body that the animation visualises.
- `game-ai` — deciding *when* to play which animation state.

© gamedev-skills · Apache-2.0 · gamedev-skills/awesome-gamedev-agent-skills

Similar skills

Everything for Game dev and 3D: Unity, Unreal, Godot, Blender →

From the same set77

steam-publish A skill that walks a finished build through Steam: depots and packages, steamcmd uploads, beta branches, review checklists. Useful when the game is ready but the store page isn't. CX Codex +1 5,900installs itch-publish This skill walks a game build onto an itch.io page: butler push to the right channel, version strings, updates that send only what changed. Handy when a demo or release has to go out. CX Codex +1 5,700installs phaser-core Skill to set up and debug Phaser 4 games: Game config, Scene lifecycle (init/preload/create/update), asset loader, cameras, and cross-scene data. Use when building or fixing a Phaser game. CX Codex +1 5,700installs game-jam Plans and scopes game development projects under tight jam deadlines, keeping scope locked to the clock so a playable build gets submitted. CX Codex +1 5,700installs threejs-gltf-loading Loads glTF/GLB models into three.js and plays their baked or skinned clips, with patterns for DRACO, Meshopt and KTX2. For the case where the file imports but nothing shows up on screen. CX Codex +1 5,600installs unity-physics Sets up 3D PhysX physics in Unity 6.3 LTS with proper Rigidbody motion, collision layers, and raycasts. Useful when writing character controllers or tuning physics interactions. CX Codex +1 5,600installs roblox-datastores Teaches the agent to persist Roblox player data through DataStoreService: load on join, save on leave and on BindToClose, retries. Useful when progress vanishes. CX Codex +1 5,700installs unity-input-system A Claude Code skill that wires player input in Unity 6.3 LTS with the Input System package: action maps, PlayerInput, values read in C#. CX Codex +1 5,700installs

Project sponsors

Companies that keep this analytics open
Gold sponsor

Impressions, clicks and code copies — open statistics. We keep the numbers public for the same reason NeBlask itself is public. Become a sponsor