diff --git a/src/action/mod.rs b/src/action/mod.rs index 3591d35..84a2b46 100644 --- a/src/action/mod.rs +++ b/src/action/mod.rs @@ -20,7 +20,6 @@ impl Plugin for CyberActionPlugin { .register_type::() .add_plugin(RapierPhysicsPlugin::::default()) .add_plugin(FrameTimeDiagnosticsPlugin::default()) - .add_startup_system(zero_gravity) .add_system(surface_fix.label("surface_fix")) .add_system(gravity.before("cat")) .add_system(falling_cat.label("cat")) diff --git a/src/action/systems.rs b/src/action/systems.rs index f19cad7..e36dc74 100644 --- a/src/action/systems.rs +++ b/src/action/systems.rs @@ -18,19 +18,15 @@ use crate::{ const PITCH_SCALE: f32 = 0.2; -/// Disable gravity in Rapier. -pub(super) fn zero_gravity(mut config: ResMut) { - config.gravity = Vec3::ZERO; -} - /// The gravity vector points from the cyberbike to the center of the planet. pub(super) fn gravity( - mut query: Query<(&Transform, &mut ExternalForce, &ReadMassProperties), With>, + mut query: Query<(&Transform, &mut ExternalForce), With>, settings: Res, + mut rapier_config: ResMut, ) { - let (xform, mut forces, mprops) = query.single_mut(); - let grav = xform.translation.normalize() * -settings.gravity * mprops.0.mass; - forces.force = grav; + let (xform, mut forces) = query.single_mut(); + rapier_config.gravity = xform.translation.normalize() * -settings.gravity; + forces.force = Vec3::ZERO; forces.torque = Vec3::ZERO; }