An ECS-based Bevy procedural and asset animation library.
This is a young plugin and APIs are to be fleshed out. Breaking changes are to be expected!
See changelog here.
-
Ergonomic and user-friendly API: API are designed to be concise, expressive, and simple to use. Animation can be built using the combinator framework.
Example
let sprite_id = commands.spawn(SpriteBundle { ... }).id(); let sprite = sprite_id.into_target(); commands.animation() .insert(tween( Duration::from_secs(1), EaseFunction::Linear, sprite.with(translation(pos0, pos1)) ));
You can also abstract animation!
fn my_animation( target: TargetComponent, duration: Duration ) -> impl FnOnce(&mut AnimationCommands, &mut Duration) { parallel(( tween(duration, EaseFunction::QuadraticOut, target.with(translation(...))), tween(duration, EaseFunction::QuadraticOut, target.with(rotation(...))), )) } let sprite_id = commands.spawn(Sprite { ... }).id(); let sprite = sprite_id.into_target(); commands.animation().insert(my_animation(sprite, Duration::from_secs(1)))
-
Flexible and Extensible: Everything is components and systems with a sprinkle of dependency injection.
- Tween anything from anywhere, built-in or custom system.
- Interpolate with any curve, built-in or custom system.
- Literally anything as long as they're time controlled.
-
Parallelism: Since a tween or an animation primitive is one component and one system, they have great chances for system parallelism and increase in performance.
-
Rich timer control:
- Looping
- Fastforward or Rewind
- Skip backward or forward
- Jumping to anywhen
See demos
Goals:
- Flexible ๐
- integration with other crates (?)
-
bevy_animation
-
bevy_lookup_curve
-
- Editor. While the original goal for this crate is tweening from code,
this crate absolutely has the capability to work on any complex animations.
The editor will aid in such jobs.
- Real-time display at any point in time in the animation.
- Editing path from point A to point B with arbitary curve.
The main motivation for this tweening crate is that the previous existing tweening crates is not flexible enough and so the main goal is to solve it.
Differences to bevy_tweening
or bevy_easings
:
- Tweening is not tied to a certain entity. You can create an entity specifically for tweening any where in the world.
- Complex animations, such as sequential or parallel tweening, are solved using
child-parent hierarchy:
- Solved the issue of modifying animation at runtime presents in the previous crates.
- Everything exists in the ECS world with no hidden structure, everything can be freely accessed.
- Makes a very extendable system, thanks Bevy's ECS!
- It's possible to have multiple
Interpolator
(orLens
if you came frombevy_tweening
) tweening the same component/asset/resource because of the design of this crate and so it is not limited by '1 component type per entitiy'.
- Advanced timer. This crate has custom timer implementation.
- Dependency injection. Systems communicate through various specific components, allowing you to extends the behavior to your needs by supplying those components and reduce duplication.
- Users of this crate are free to decide if they want to only use generic, only trait object, or even both for tweening, or even something else entirely.
- Defaults
bevy_asset
Add tweening systems for asset.bevy_render
Currently add nothing but required by thebevy_sprite
feature.bevy_sprite
Add some built-in interpolators related to sprite.bevy_ui
Add some built-in interpolators related to ui.bevy_eventlistener
Add entity-targeted events with bevy_eventlistener.
- Optional
bevy_lookup_curve
.
Adds interpolation implementation usingbevy_lookup_curve
.
bevy |
bevy_tween |
---|---|
0.13 | 0.2โ0.5 |
-
The first crate I discovered and tried to do tweening with in Bevy. Their method of
Lens
is great and so it's present in this crate. Now calledInterpolator
. Usages may be similar but is implemented differently. -
Godot's tween make it simple to animate something which is the inspiration for this crate. The multi-entity architecture is mainly inspired by Godot's node child-parent hierarchy system and that most of the engine APIs utilizes this to define behavior.
Contributions are welcome!
Licensed under either of
- Apache License, Version 2.0, (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.
cargo run --example follow -F bevy/bevy_winit
A square will follow your circle with configurable animation.
follow.mp4
cargo run --example click -F bevy/bevy_winit
Click left to spawn a circle. Hold right click to repetitively spawn a circle every frame.
hm.mp4
cargo run --example hold -F bevy/bevy_winit
Hold left click to increase the effect intensitiy.
hold.mp4
cargo run --example event -F bevy/bevy_winit
Showcasing the tween event feature.
2024-04-14.15-52-03.mp4
cargo run --example sprite_sheet -F bevy/bevy_winit
Sprite Sheet animation.