Skills

Bevy Animation Graph

Bevy ECS skill for animation blending.

Install

npx skills add thedivergentai/Game-Dev-Agentic-Skills --skill bevy-animation-graph -g -a claude-code -y
Category
Design
Updated
19d ago
License
LGPL-3.0
Context cost
Mediumabout 2,093 tokens
Runs scripts
No, instructions only

What it does

Bevy ECS skill for animation blending. Keywords: Bevy, AnimationGraph, blend, AnimationGraphHandle, AnimationNodeType.

Bevy animation graph

When to use

Load this when clips must blend, add, or mask. Single-clip playback stays on bevy-animation.

ECS shape

  • Assets: AnimationGraph describes how clips blend. add_clip parents a clip node. add_blend parents a blend node. add_clip_with_mask stores a u64 mask (bone groups you assign; 0 means no mask).
  • Components: AnimationGraphHandle is a handle to the graph used by the AnimationPlayer on the same entity. AnimationTransitions crossfades between nodes.
  • Weights: ActiveAnimation::set_weight on the player, after play, drives a node that is already in the graph.
  • Systems: evaluation still runs through the animation player systems. Do not add a second player.
#[derive(Resource)]
struct LocomotionNodes {
    graph: Handle<AnimationGraph>,
    walk: AnimationNodeIndex,
    run: AnimationNodeIndex,
}

fn build_locomotion_graph(
    mut commands: Commands,
    asset_server: Res<AssetServer>,
    mut graphs: ResMut<Assets<AnimationGraph>>,
) {
    let mut graph = AnimationGraph::new();
    let blend = graph.add_blend(0.5, graph.root);
    let walk = graph.add_clip(
        asset_server.load(GltfAssetLabel::Animation(0).from_asset("models/fox.glb")),
        1.0,
        blend,
    );
    let run = graph.add_clip_with_mask(
        asset_server.load(GltfAssetLabel::Animation(1).from_asset("models/fox.glb")),
        0b0011,
        1.0,
        blend,
    );
    let handle = graphs.add(graph);
    commands.insert_resource(LocomotionNodes {
        graph: handle,
        walk,
        run,
    });
}
#[derive(Resource)]
struct LocomotionNodes {
    graph: Handle<AnimationGraph>,
    walk: AnimationNodeIndex,
    run: AnimationNodeIndex,
}
Read the whole SKILL.md on GitHub

More in Design