#bevy-animation #animation #gltf #bevy #gamedev

bevy_gltf_animation

Minimal animation setup for gltf files

2 releases

Uses new Rust 2024

new 0.1.1 May 11, 2025
0.1.0 May 11, 2025

#1334 in Game dev

40 downloads per month

MIT/Apache

40KB
202 lines

Easy animations for GLTF files

github crates.io

Purpose

GLTF files include animations in their files. Importing them into bevy can be tedious, especially if you don't plan to blend any animations.

This crate automatically creates a handler for your animations per scene root based on the imported GLTF file.

Example

use bevy::prelude::*;
use bevy_gltf_animation::prelude::*;

fn main() {
    App::new()
        .add_plugins((DefaultPlugins, GltfAnimationPlugin))
        .add_systems(Startup, setup)
        .add_systems(Update, play_animations)
        .run();
}


fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
    // spawns a SceneRoot and GltfAnimations on this component
    commands.spawn(GltfSceneRoot::new(asset_server.load("human.glb")));
}
// once gltf animations have been added, play animation 2.
fn play_animations(
    animations: Query<&mut GltfAnimations, Added<GltfAnimations>>,
    mut players: Query<&mut AnimationPlayer>,
) {
    for mut gltf_animations in animations {
        let index = gltf_animations.get(2).unwrap();
        // if named, you can use
        // let index = gltf_animations.get("Walking_Forward").unwrap()
        let mut player = players.get_mut(gltf_animations.animation_player).unwrap();
        player.play(index);
    }
}

Contributing/Suggestions

This crate does one thing, but I want it to do that thing very well. Please describe your usecase in an issue or PR if you are looking for particular functionality!

Dependencies

~47–79MB
~1.5M SLoC