Bevy Sequential Actions
A simple library for managing and sequencing various actions in Bevy.
📜 Getting Started
Plugin
The quickest way for getting started is adding the SequentialActionsPlugin to your App.
use *;
Implementing an Action
An action is anything that implements the Action trait.
The trait contains various methods that together defines the lifecycle of an action.
From this, you can create any action that can last as long as you like,
and do as much as you like.
An entity with actions is referred to as an agent.
A simple wait action follows.
;
Managing Actions
Actions can be added to any Entity with the SequentialActions marker component.
Adding and managing actions is done through the actions(agent)
extension method implemented for both Commands and World.
See the ManageActions trait for available methods.
⚠️ Warning
Since you are given a mutable World, you can in practice do anything.
Depending on what you do, the logic for advancing the action queue might not work properly.
There are a few things you should keep in mind:
-
If you want to despawn an
agentas an action, this should be done inon_start. -
The
executeandnextmethods should not be used, as that will immediately advance the action queue while inside any of the trait methods. Instead, you should returntrueinon_start. -
When adding new actions, you should set the
startproperty tofalse. Otherwise, you will effectively callexecutewhich, again, should not be used. At worst, you will cause a stack overflow if the action adds itself.
📎 Examples
See the examples for more usage.
Each example can be run with cargo run --example <example>.
| Example | Description |
|---|---|
basic |
Basic usage of the library. |
pause |
Pause and resume an action. |
repeat |
Create an action that repeats. |
parallel |
Create actions that run in parallel. |
sequence |
Create action with a sequence of actions. |
custom |
Custom plugin with different schedules and action queue advancement. |
📌 Compatibility
| bevy | bevy-sequential-actions |
|---|---|
| 0.17 | 0.14 |
| 0.16 | 0.13 |
| 0.15 | 0.12 |
| 0.14 | 0.11 |
| 0.13 | 0.10 |
| 0.12 | 0.9 |
| 0.11 | 0.8 |
| 0.10 | 0.7 |
| 0.9 | 0.6 |
| 0.8 | 0.3 – 0.5 |
| 0.7 | 0.1 – 0.2 |
🔖 License
bevy-sequential-actions is dual-licensed under either
- MIT License (LICENSE-MIT or http://opensource.org/licenses/MIT)
- Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
at your option.