bevy_tweening : a tweening animation plugin for Bevy #3432
djeedai
started this conversation in
Show and tell
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi all-
I'm delighted to announce the publishing of
bevy_tweening
(crates.io, github), a plugin for Bevy to do easing / tweening interpolation-based animation.Note: This is currently only available for v0.5. Unfortunately I do not have time to maintain two separate versions for stable and main, especially as the gap between v0.5 and main is very large. I hope the Bevy leadership team can find a better release model to facilitate support for third-party plugins and avoid this overhead for maintainers.
Overview
The plugin was heavily inspired by
bevy_easings
from @mockersf, but explores different design choices regarding access to animated fields and animation of assets. Namely:Animator<T: Component>
component generic on the Bevy component to animate only, and not on the field(s) accessed. This reduces the number of systems and animation components to instantiate.Lens
trait -- decides which field(s) of the component is/are interpolated. This saves work if for example only the rotation of aTransform
needs to be animated.&mut
reference, and the lens overwrite it with the newly interpolated value. This potentially save on allocations, and avoid having to create a new instance of the component each time likebevy_easings
currently require, which is at least cumbersome if not inefficient.ColorMaterial
can be animated via anAssetAnimator
component, which again mutates via a lens the asset in-place, avoiding the need to create many copies.The plugin provides a few predefined lenses for commonly animated component/fields and assets, and allows you to write your own lens to animate virtually any field of any component or asset.
Hello World
Add the plugin to your app:
Add an
Animator
component (or anAssetAnimator
one if you animate an asset) and specify a lens for the component's fields:Future Works
Entity
, you cannot add multiple lenses to animate different parts of the same component with different parameters, since theAnimator
is generic over the component to animate, and therefore defines a unique component typeAnimator<T>
per animated component typeT
.bevy_easings
in the benchmarks to evaluate the design decisions with data, and see which approach is more promising in terms of performance.Beta Was this translation helpful? Give feedback.
All reactions