4 releases (2 breaking)

0.4.0 Apr 8, 2024
0.3.1 Apr 4, 2024
0.2.0 Mar 14, 2024
0.1.3 Mar 6, 2024

#373 in Game dev

Download history 321/week @ 2024-03-03 138/week @ 2024-03-10 20/week @ 2024-03-17 1/week @ 2024-03-24 198/week @ 2024-03-31 141/week @ 2024-04-07 15/week @ 2024-04-14

358 downloads per month

MIT/Apache

10MB
3K SLoC

Crates.io Version Crates.io License Docs.rs

bevy_tween

Flexible tweening plugin for Bevy. This crate solves for tweening animation with the approach of integrating everything into Bevy's ECS and uses dependency injection, allowing you to exploits the already flexible ECS systems to tune and extends the animation process to your needs.

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 via splines.
  • integration with other crates (?)
    • bevy_animation
  • Editor. While the original goal is to just be a tweening from code crate, 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.

Demos

This is an interactive demo. The square will follow your circle with configurable animation.
cargo run --example follow -F bevy/bevy_winit

https://github.com/Multirious/bevy_tween/assets/77918086/d582c2de-0f54-4b22-be03-e3bff3348deb


This is an interactive demo. Click left to spawn a circle. Hold right click to repetitively spawn a circle every frame.
cargo run --example click -F bevy/bevy_winit

https://github.com/Multirious/bevy_tween/assets/77918086/369abdec-32d0-482f-8f2d-b9bb8829ceca


This is an interactive demo. Hold left click to increase the effect intensitiy.
cargo run --example hold -F bevy/bevy_winit

https://github.com/Multirious/bevy_tween/assets/77918086/33a297a6-19f2-4146-a906-1a88ff037ab3


This is a non interactive demo, showcasing the tween event feature.
cargo run --example event -F bevy/bevy_winit

https://github.com/Multirious/bevy_tween/assets/77918086/593c9b64-6e7f-40bf-b0b7-29671f971e6e

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.

Dependencies

~16–59MB
~1M SLoC