From c6838a3fc5da88027ff40e0a4763e52a2f71ca90 Mon Sep 17 00:00:00 2001 From: Elijah Voigt Date: Sat, 26 Jul 2025 14:52:13 -0700 Subject: [PATCH] The bird is moving along --- src/bin/flappy/main.rs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/bin/flappy/main.rs b/src/bin/flappy/main.rs index 37f86a2..7b787eb 100644 --- a/src/bin/flappy/main.rs +++ b/src/bin/flappy/main.rs @@ -91,7 +91,8 @@ fn init_bird( let physics = ( RigidBody::Dynamic, Collider::capsule(1.0, 1.0), Mass(1.0), - ExternalForce::default().with_persistence(false), + ExternalForce::new(Vec3::X * 1.0).with_persistence(true), + ExternalImpulse::default().with_persistence(false), LockedAxes::ROTATION_LOCKED.lock_translation_z(), ); @@ -113,7 +114,7 @@ fn init_ground( ..default() })); - let mesh = Mesh3d(meshes.add(Cuboid::new(5.0, 1.0, 1.0))); + let mesh = Mesh3d(meshes.add(Cuboid::new(10.0, 1.0, 1.0))); let name = Name::new("ground"); @@ -149,7 +150,7 @@ fn init_ui( fn flap( #[cfg(debug_assertions)] state: Res>, #[cfg(debug_assertions)] keycode: Res>, - mut bird: Query<(&Transform, &mut ExternalForce), With>, + mut bird: Query<(&Transform, &mut ExternalImpulse), With>, ) { debug_assert!( matches!(state.get(), PlayerState::Alive), @@ -161,7 +162,7 @@ fn flap( ); bird.iter_mut().for_each(|(t, mut f)| { - f.apply_force(t.rotation * Vec3::NEG_Z * 500.0); + f.apply_impulse(t.rotation * Vec3::NEG_Z * 5.0); }); }