From 69403bc6cad3440e37fceee2678d45a7f9252289 Mon Sep 17 00:00:00 2001 From: Robert Garrett Date: Tue, 2 Sep 2025 15:44:39 -0500 Subject: [PATCH] Fix the physics integrator The velocity component never got updated. Instead, the system was only calculating the current frame's deltaV. That instantaneous dV and any velocity that *did* get assigned (bundle insertion, keyboard control) would be added to the position. Now forces are integrated into velocity, and velocity is integrated into position. You know... like a real integration function. --- src/birdoids/physics.rs | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/src/birdoids/physics.rs b/src/birdoids/physics.rs index 20b3e875..bdbb9468 100644 --- a/src/birdoids/physics.rs +++ b/src/birdoids/physics.rs @@ -1,16 +1,23 @@ use bevy::prelude::*; -#[derive(Component, Deref, DerefMut)] +#[derive(Component, Default, Deref, DerefMut)] pub struct Velocity(pub Vec3); #[derive(Component, Default, Deref, DerefMut, PartialEq, Debug)] pub struct Force(pub Vec3); -pub fn apply_velocity(mut query: Query<(&mut Transform, &Velocity, &mut Force)>, time: Res