Bevy MotionGfx

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;
App::new()
.add_plugins((DefaultPlugins, BevyMotionGfxPlugin))
.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,
mut motiongfx: ResMut<MotionGfxWorld>,
) {
let entity = commands
.spawn(Transform::from_xyz(-3.0, 0.0, 0.0))
.id();
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();
commands.spawn(motiongfx.add_timeline(timeline));
}
This example demonstrates how to animate an Asset.
use bevy::prelude::*;
use bevy_motiongfx::prelude::*;
fn build_timeline(
mut commands: Commands,
mut motiongfx: ResMut<MotionGfxWorld>,
mut materials: ResMut<Assets<StandardMaterial>>
) {
let material =
materials.add(StandardMaterial::from_color(Srgba::BLUE));
commands.spawn(MeshMaterial3d(material.clone()));
let mut b = TimelineBuilder::new();
let track = b
.act_interp(
material.untyped().id(),
field!(<StandardMaterial>::base_color),
|_| Srgba::RED.into(),
)
.play(1.0)
.compile();
b.add_tracks(track);
let timeline = b.compile();
commands.spawn(motiongfx.add_timeline(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,
mut motiongfx: ResMut<MotionGfxWorld>,
) {
let mut b = TimelineBuilder::new();
let timeline = b.compile();
commands.spawn((
motiongfx.add_timeline(timeline),
RealtimePlayer::new().with_playing(true),
));
}
Version Matrix
| Bevy |
MotionGfx |
Bevy MotionGfx |
| 0.18 |
0.2 |
0.2 |
| 0.17 |
0.1 |
0.1 |
License
bevy_motiongfx is dual-licensed under either:
This means you can select the license you prefer!
This dual-licensing approach is the de-facto standard in the Rust ecosystem and there are very good reasons to include both.