bevy_animations is a Lightweight 2d animations engine built for Bevy
Bevy Animations is still in beta and may incurr major API and backend changes in the future.
What bevy_animations accomplishes
- Fully incorporated with Bevy ECS
- Easy to use builder pattern syntax
- Creates animations to use on entities with custom configuration
- Automatic dropping of animating entites
Add bevy_animations to your Bevy App
use AnimationsPlugin;
use *;
How bevy_animations animations work
- specified timings or
meters_per_frame
for each frame - user defining which y indexes are left, right, up and down facing sprites or if the sprites should be flipped instead
- certain animations can block others from happening
- utilizing a priortity based system so you can define multiple blocking animations with different priorities to render
How to define a bevy_animations animation
You first need to spawn an entity using Commands
like this
use *;
use *;
Note if you don't add the AnimationDirection
component to your entity it will seem as though your animations will never be inserted because bevy_animations
is looking for the
AnimationDirection
component in it's Query
s
You can then add your animations to ResMut<Animations>
like this
animations.insert_animation
Note if you have a one directional animation you can use AnimationDirectionIndexes::one_directional()
Note it is on you to make sure you are passing the correct strings to bevy_animations to animate your entity
You can also add a TimedAnimation
like this
animations.insert_animation
We can then start an animation by sending it over an EventWriter<AnimationEvent>
like this
-
Note that you can send an event of the same name multiple times even while an animation is in progress without ruining it
-
Note an animation that has been sent will animate till end or repeat forever
If you want to change the direction of the animation you will query it from the AnimatingEntity
like this
- Note if you send an event with a different name the current animation of the entity will change immediately unless the current animation is blocking or has a higher priority.
Knowing this you can change the player_running
animation to player_die
in another system where you could check collisions like this
-
Note that
bevy_animations
will automatically remove your entity from it's own data structure if it doesn't exist in theWorld
i.e when the entity despawns via.despawn()
-
Note there is no functionality internally yet for doing a task like despawning an entity only after an animation is finished. This can be accomplished on your own however.
Versioning
bevy | bevy_animations |
---|---|
0.13.x | 0.6.x |
0.12.x | 0.5.x |
0.11.x | 0.4.x |
0.10.x | 0.3.x |
0.9.x | 0.2.x |
More Documentation
If you need more in depth Documentation and more examples for all of the current implementations read the bevy_animations book or visit the api docs
Open Source
bevy_animations is open-source forever. You can contribute via the GitHub Repo