Crates.io | bevy_tween |
lib.rs | bevy_tween |
version | 0.6.0 |
source | src |
created_at | 2024-03-04 11:22:37.335703 |
updated_at | 2024-07-08 01:54:53.799527 |
description | Flexible tweening plugin library for Bevy |
homepage | https://github.com/Multirious/bevy_tween |
repository | https://github.com/Multirious/bevy_tween |
max_upload_size | |
id | 1161616 |
size | 401,679 |
bevy_tween
Bevy procedural and keyframe 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: You can always spawn the animator manually but this crate provide APIs that abstracted over most boilerplate code. Animation can be built using the builder with function combinators.
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: This crate is built on top of bevy_time_runner
which mean we can extend this crate by adding any components and systems.
Parallelism: Tweens are typed and can be query over by their typed system which increase chances for system parallelism.
Rich timer control:
See demos
Goals:
bevy_animation
bevy_lookup_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
:
Interpolator
(or Lens
if you came from bevy_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'.bevy_asset
bevy_render
bevy_sprite
feature.bevy_sprite
bevy_ui
bevy_eventlistener
bevy_lookup_curve
.bevy_lookup_curve
.bevy |
bevy_tween |
---|---|
0.14 | 0.6 |
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 called Interpolator
. 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
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.
https://github.com/Multirious/bevy_tween/assets/77918086/d582c2de-0f54-4b22-be03-e3bff3348deb
cargo run --example click -F bevy/bevy_winit
Click left to spawn a circle. Hold right click to repetitively spawn a circle every frame.
https://github.com/Multirious/bevy_tween/assets/77918086/fd0fe9d3-13a2-4261-880c-cc2609b875ba
cargo run --example hold -F bevy/bevy_winit
Hold left click to increase the effect intensitiy.
https://github.com/Multirious/bevy_tween/assets/77918086/33a297a6-19f2-4146-a906-1a88ff037ab3
cargo run --example event -F bevy/bevy_winit
Showcasing the tween event feature.
https://github.com/Multirious/bevy_tween/assets/77918086/9507c467-6428-4aed-bd00-511f05e6e951
cargo run --example sprite_sheet -F bevy/bevy_winit
Sprite Sheet animation.
https://github.com/Multirious/bevy_tween/assets/77918086/e3997b06-38e6-4add-85f5-a885b69c6687