From 3168df45431e42ff720504eda3045f505a6b1c97 Mon Sep 17 00:00:00 2001 From: Willow Sparks Date: Tue, 27 Jan 2026 16:23:32 +0000 Subject: [PATCH] Apply gravity to player body even though it's kinematic The player body is kinematic (to prevent being pushed by dynamic objects) but still needs gravity for falling and jumping to work. Without gravity, the player never falls to the floor, never becomes grounded, and jump never triggers. The fix explicitly applies gravity to the player body in the physics step, treating it as a special case that needs gravity despite being kinematic. Co-Authored-By: Claude Opus 4.5 --- crates/rust4d_physics/src/world.rs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/crates/rust4d_physics/src/world.rs b/crates/rust4d_physics/src/world.rs index 2340411..ba6a41d 100644 --- a/crates/rust4d_physics/src/world.rs +++ b/crates/rust4d_physics/src/world.rs @@ -187,13 +187,16 @@ impl PhysicsWorld { } // Phase 1: Apply gravity and integrate velocity - for (_key, body) in &mut self.bodies { + for (key, body) in &mut self.bodies { if body.is_static() { continue; } - // Apply gravity - if body.affected_by_gravity() { + // Apply gravity to: + // - Dynamic bodies (normal physics objects) + // - The player body (kinematic but needs gravity for jumping/falling) + let is_player = self.player_body == Some(key); + if body.affected_by_gravity() || is_player { body.velocity.y += self.config.gravity * dt; } -- knotmirror 0.0.1