18 lines
438 B
Rust
18 lines
438 B
Rust
use bevy::prelude::*;
|
|
|
|
#[derive(Component, Reflect)]
|
|
#[reflect(Component)]
|
|
pub struct AutoRotation(pub Quat);
|
|
|
|
pub fn plugin(app: &mut App) {
|
|
app.register_type::<AutoRotation>();
|
|
|
|
app.add_systems(FixedUpdate, update_auto_rotation);
|
|
}
|
|
|
|
fn update_auto_rotation(mut query: Query<(&AutoRotation, &mut Transform)>) {
|
|
for (auto_rotation, mut transform) in query.iter_mut() {
|
|
transform.rotate_local(auto_rotation.0);
|
|
}
|
|
}
|