aboutsummaryrefslogtreecommitdiff
path: root/plugins/movement/src/lib.rs
diff options
context:
space:
mode:
author魏曹先生 <1992414357@qq.com>2026-08-08 15:27:04 +0800
committer魏曹先生 <1992414357@qq.com>2026-08-08 15:27:04 +0800
commit52e0befc296dd58e49de2aeec4cee78be9772639 (patch)
tree8a1bfaeef8b4fcf630c9bb9a61430a5a6d3fd3c9 /plugins/movement/src/lib.rs
parentfc0d77d6838b16d811ffe5e999d3d77d499b470f (diff)
chore: use bevy Transform for movement
Replace the custom Position component with Bevy's built-in Transform for entity movement.
Diffstat (limited to 'plugins/movement/src/lib.rs')
-rw-r--r--plugins/movement/src/lib.rs18
1 files changed, 9 insertions, 9 deletions
diff --git a/plugins/movement/src/lib.rs b/plugins/movement/src/lib.rs
index f7f6ba5..d279d3b 100644
--- a/plugins/movement/src/lib.rs
+++ b/plugins/movement/src/lib.rs
@@ -4,21 +4,23 @@
//!
//! # Included
//!
-//! - **Velocity**: Represents the entity's current momentum, used by systems to calculate the next frame's position
-//! - **Position**: Represents the entity's current location
+//! - **Velocity**: Represents the entity's current momentum, used by systems to calculate the next frame's translation
//! - **Movement**: A pure marker, used to flag this entity as movable
//! - **VelocityReducer**: Controls how Velocity is reduced
+//!
+//! Movement is applied to the entity's [`Transform::translation`].
#![deny(missing_docs)]
use bevy::{
app::{FixedUpdate, Plugin},
ecs::{query::With, system::Query},
+ transform::components::Transform,
};
use ch_macro_rules::import;
// Basic data
-import!(position, velocity, movement);
+import!(velocity, movement);
// Modifiers
import!(reducer);
@@ -35,13 +37,11 @@ impl Plugin for CHMovementPlugins {
}
fn update_movement(
- query: Query<(&mut Position, &mut Velocity, Option<&VelocityReducer>), With<Movement>>,
+ query: Query<(&mut Transform, &mut Velocity, Option<&VelocityReducer>), With<Movement>>,
) {
- for (mut pos, mut velo, reducer) in query {
- // Add Velocity to Position
- pos.x += velo.x;
- pos.y += velo.y;
- pos.z += velo.z;
+ for (mut transform, mut velo, reducer) in query {
+ // Add Velocity to the entity's translation
+ transform.translation += **velo;
// Apply velocity reduction (default to Lerp(0.25) if no reducer present)
match reducer {