From 52e0befc296dd58e49de2aeec4cee78be9772639 Mon Sep 17 00:00:00 2001 From: 魏曹先生 <1992414357@qq.com> Date: Sat, 8 Aug 2026 15:27:04 +0800 Subject: chore: use bevy Transform for movement Replace the custom Position component with Bevy's built-in Transform for entity movement. --- plugins/movement/src/lib.rs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'plugins/movement/src/lib.rs') 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>, + query: Query<(&mut Transform, &mut Velocity, Option<&VelocityReducer>), With>, ) { - 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 { -- cgit