The bird is moving along

main
Elijah Voigt 3 months ago
parent f68b052f2d
commit c6838a3fc5

@ -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<State<PlayerState>>,
#[cfg(debug_assertions)] keycode: Res<ButtonInput<KeyCode>>,
mut bird: Query<(&Transform, &mut ExternalForce), With<Bird>>,
mut bird: Query<(&Transform, &mut ExternalImpulse), With<Bird>>,
) {
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);
});
}

Loading…
Cancel
Save