2 releases

Uses new Rust 2024

0.1.0-rc.2 Oct 31, 2025
0.1.0-rc.1 Oct 23, 2025

#427 in Visualization

MIT/Apache

98KB
2.5K SLoC

Bevy MotionGfx

License Crates.io Downloads Docs Discord

An integration of the MotionGfx crate for the Bevy game engine.

Usage

Initialization

The BevyMotionGfxPlugin must be added for timeline and controllers to work.

use bevy::prelude::*;
use bevy_motiongfx::BevyMotionGfxPlugin;
use bevy_motiongfx::prelude::*;

App::new()
    .add_plugins((DefaultPlugins, BevyMotionGfxPlugin))
    // Add systems here...
    .run();

Create Animations

For a more thorough walkthrough on the Timeline API, read the MotionGfx docs.

This example demonstrates how to animate an Entity.

use bevy::prelude::*;
use bevy_motiongfx::prelude::*;

fn build_timeline(mut commands: Commands) {
    // Spawn the Entity.
    let entity = commands
        .spawn(Transform::from_xyz(-3.0, 0.0, 0.0))
        .id();

    // Build the timeline.
    let mut b = TimelineBuilder::new();
    let track = b
        .act_interp(entity, field!(<Transform>::translation::x), |x| {
            x + 6.0
        })
        .play(1.0)
        .compile();

    b.add_tracks(track);
    let timeline = b.compile();

    // Spawn the timeline.
    commands.spawn(timeline);
}

This example demonstrates how to animate an Asset.

use bevy::prelude::*;
use bevy_motiongfx::prelude::*;

fn build_timeline(
    mut commands: Commands,
    mut materials: ResMut<Assets<StandardMaterial>>
) {
    // Create the asset.
    let material =
        materials.add(StandardMaterial::from_color(Srgba::BLUE));
    // Spawn an entity to prevent the asset from dropping.
    commands.spawn(MeshMaterial3d(material.clone()));

    // Build the timeline.
    let mut b = TimelineBuilder::new();
    let track = b
        .act_interp(
          // AssetIds must be type-erased.
          material.untyped().id(),
          field!(<StandardMaterial>::base_color),
          |_| Srgba::RED.into(),
        )
        .play(1.0)
        .compile();

    b.add_tracks(track);
    let timeline = b.compile();

    // Spawn the timeline.
    commands.spawn(timeline);
}

Controllers

Controllers are helper components for automating the target time and target track of a Timeline.

use bevy::prelude::*;
use bevy_motiongfx::prelude::*;

fn build_timeline(mut commands: Commands) {
    // Build the timeline.
    let mut b = TimelineBuilder::new();
    // Add tracks here...
    let timeline = b.compile();

    // Spawn the timeline with a controller.
    commands
        .spawn((timeline, RealtimePlayer::new().with_playing(true)));
}

Version Matrix

Bevy MotionGfx Bevy MotionGfx
0.17 0.1 0.1

Dependencies

~18–59MB
~1M SLoC