From 3cbdb522f21ccf6ab97eccc114537b9c72607210 Mon Sep 17 00:00:00 2001 From: Joe Ardent Date: Tue, 8 Feb 2022 22:00:05 -0800 Subject: [PATCH] Replicates old feel with Rapier-native code. --- src/action.rs | 44 ++++++++++++++++++++++++++------------------ src/geometry.rs | 2 +- src/main.rs | 6 ++---- 3 files changed, 29 insertions(+), 23 deletions(-) diff --git a/src/action.rs b/src/action.rs index f86b184..f05a345 100644 --- a/src/action.rs +++ b/src/action.rs @@ -10,8 +10,6 @@ use crate::{ pub struct MovementSettings { pub sensitivity: f32, pub accel: f32, - pub drag: f32, - pub gravity: f32, } impl Default for MovementSettings { @@ -19,8 +17,6 @@ impl Default for MovementSettings { Self { sensitivity: 1.0, accel: 40., - drag: 0.0005, - gravity: 10.0, } } } @@ -37,6 +33,12 @@ fn setup_colliders( }; let pcollide = ColliderBundle { shape: ColliderShape::ball(PLANET_RADIUS).into(), + material: ColliderMaterial { + friction: 0.0, + restitution: 0.3, + ..Default::default() + } + .into(), ..Default::default() }; commands @@ -47,12 +49,24 @@ fn setup_colliders( let (bike, xform) = bike_query.single(); let mut bbody = RigidBodyBundle::default(); bbody.damping.angular_damping = 0.8; - bbody.damping.linear_damping = 0.4; + bbody.damping.linear_damping = 0.5; let isometry = Isometry::from_parts(xform.translation.into(), xform.rotation.into()); bbody.position = isometry.into(); // collider + let shape = ColliderShape::capsule( + Vec3::new(0.0, 0.0, -1.25).into(), + Vec3::new(0.0, 0.0, 1.2).into(), + 0.4, + ); let bcollide = ColliderBundle { - shape: ColliderShape::ball(1.1).into(), + shape: shape.into(), + mass_properties: ColliderMassProps::Density(0.3).into(), + material: ColliderMaterial { + friction: 0.0, + restitution: 0.3, + ..Default::default() + } + .into(), ..Default::default() }; commands @@ -63,30 +77,26 @@ fn setup_colliders( } fn gravity(xform: Query<&Transform, With>, mut config: ResMut) { - let gravity = xform.single().translation.normalize() * -10.0; + let gravity = xform.single().translation.normalize() * -8.0; config.gravity = gravity.into(); } fn falling_cat( - time: Res