Crates.io | bevy_action |
lib.rs | bevy_action |
version | 0.1.0 |
source | src |
created_at | 2023-04-07 21:47:24.477289 |
updated_at | 2023-04-07 21:47:24.477289 |
description | Simple action system for Bevy. |
homepage | https://github.com/undersquire/bevy_action |
repository | https://github.com/undersquire/bevy_action |
max_upload_size | |
id | 833217 |
size | 16,076 |
Simple action system for Bevy.
This plugin exists mainly to facilitate a common action system for other plugins to hook in to (e.g. bevy_action_animation
).
It also serves as a way to decouple certain parts of game logic to avoid hard-coding things, such as hard-coding input handling to actions rather than directly to movement logic.
There are three main components, the Action
trait, the ActionEvent
event, and the ActionPlugin
.
Start by defining your own type to represent the actions (enum is recommended).
You will then need to derive the required traits and manually implement the Action
trait (this will be derivable in the future):
#[derive(Clone, Debug, PartialEq, Eq, Hash, Default, Serialize, Deserialize, TypeUuid)]
#[uuid = "UUID_HERE"]
enum MyAction {
#[default]
Idle,
Left,
Right,
Jump
}
impl Action for MyAction {}
Next, register the plugin using this type as the generic parameter:
fn main() {
App::new()
...
.add_plugin(ActionPlugin::<MyAction>::default())
...
}
Now, ActionEvent
can be used with EventReader
and EventWriter
just like any normal Bevy event.
Bevy Version | Plugin Version |
---|---|
0.10.x | 0.1 |