Skip to content

Multirious/bevy_tween

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

Crates.io Version Crates.io License Docs.rs

bevy_tween

A fully ECS-based Bevy animation library. Focuses mainly on tweening but being decoupled and flexible and so can do much more.

This is a young plugin and APIs are to be fleshed out. Breaking changes are to be expected!

See changelog here.

Features

  • ECS-based animation data and system with flexible and modular APIs powered by Bevy. Use anything you want to use. Remove anything you don't want. Extends anything that's not there.
  • Tween anything, from anywhere.
    • Colors, sprite sheet frames, positions, you define it!
    • Components, assets, resources, you implement it!
  • Interpolate with anything
    • Robert Penner's easing functions
    • Closure
    • Or implement one your self!
  • Animate at any complexity
  • Events at arbitary time (with custom data).
  • Timer
    • Looping
    • Fastforward or Rewind
    • Skip backward or forward
    • Jumping to anywhen

Goals:

  • Flexible ๐ŸŽ‰
  • Built-in Keyframe animation support.
  • 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 using splines.

Differences

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 (or Lens if you came from bevy_tweening) tweening the same component/asset/resource because of the multi-entities architecture 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.
    • Custom tweens, targets, and interpolators
    • Custom interpolations
    • Custom tweeners
  • Users of this crate are free to decide if they want to only use generic, only trait object, or even both for tweening! They both came with their pros and cons which will be explained in the documentation.
  • Flexibility at the cost of verbosity. APIs can be more verbose than the mentioned crates without extra shortcut and helpers.

Feature gates

  • "span_tween", enabled by default.
    Tween for a range of time.
  • "bevy_asset", enabled by default.
    enable "bevy/bevy_asset", add tweening systems for asset.
  • "bevy_render", enabled by default.
    enable "bevy/bevy_render", add nothing but required by the "bevy_sprite" feature.
  • "bevy_sprite", enabled by default.
    enable "bevy/bevy_sprite", add some built-in interpolator related to sprite.

Bevy Version Support

bevy bevy_tween
0.13 0.2โ€“0.4

Credits

  • bevy_tweening

    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

    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

Contributions are welcome!

License

Licensed under either of

at your option.

Your contributions

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.

Demos

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.

2024-04-14.15-42-44.mp4