From cd1649056392a6da9bc2454a99d9422e00695b94 Mon Sep 17 00:00:00 2001 From: Joe Ardent Date: Sun, 13 Feb 2022 13:58:49 -0800 Subject: [PATCH] Just more physics tweaks. Things are stable and it doesn't get its steering stuck, plus it spawns near the ground. --- src/action.rs | 16 ++++++++++++++-- src/geometry.rs | 4 ++-- src/main.rs | 5 +++-- 3 files changed, 19 insertions(+), 6 deletions(-) diff --git a/src/action.rs b/src/action.rs index dca0479..358f0af 100644 --- a/src/action.rs +++ b/src/action.rs @@ -39,6 +39,7 @@ fn setup_colliders( ..Default::default() } .into(), + mass_properties: ColliderMassProps::Density(0.0).into(), ..Default::default() }; commands @@ -47,9 +48,20 @@ fn setup_colliders( .insert_bundle(pcollide); let (bike, xform) = bike_query.single(); + setup_bike(bike, xform, &mut commands); +} + +fn setup_bike(bike: Entity, xform: &Transform, commands: &mut Commands) { let mut bbody = RigidBodyBundle::default(); - bbody.damping.angular_damping = 0.7; - bbody.damping.linear_damping = 0.4; + bbody.damping.angular_damping = 0.5; + bbody.damping.linear_damping = 0.3; + bbody.forces = RigidBodyForces { + torque: Vec3::ZERO.into(), + ..Default::default() + } + .into(); + bbody.mass_properties = + MassProperties::new(Vec3::ZERO.into(), 0.5, Vec3::new(0.0, 0.01, 0.0).into()).into(); let isometry = Isometry::from_parts(xform.translation.into(), xform.rotation.into()); bbody.position = isometry.into(); // collider diff --git a/src/geometry.rs b/src/geometry.rs index 4c63f66..5ef4c58 100644 --- a/src/geometry.rs +++ b/src/geometry.rs @@ -3,7 +3,7 @@ use bevy::prelude::*; use crate::Label; pub const PLANET_RADIUS: f32 = 860.0; -pub(crate) const SPAWN_ALTITUDE: f32 = PLANET_RADIUS + 100.0; +pub(crate) const SPAWN_ALTITUDE: f32 = PLANET_RADIUS + 2.0; #[derive(Component, Debug)] pub struct CyberBike; @@ -44,7 +44,7 @@ fn spawn_cyberbike(mut commands: Commands, asset_server: Res) { translation: Vec3::new(SPAWN_ALTITUDE, 0.0, 0.0), ..Default::default() } - .looking_at(Vec3::ZERO, Vec3::Y), + .looking_at(Vec3::new(PLANET_RADIUS, 1000.0, 0.0), Vec3::X), GlobalTransform::identity(), )) .with_children(|rider| { diff --git a/src/main.rs b/src/main.rs index aef7561..aad8dcc 100644 --- a/src/main.rs +++ b/src/main.rs @@ -11,13 +11,14 @@ use cyber_rider::{ }; const MOVEMENT_SETTINGS: MovementSettings = MovementSettings { - sensitivity: 50.0, // default: 1.0 - accel: 12.0, // default: 40.0 + sensitivity: 10.0, // default: 1.0 + accel: 20.0, // default: 40.0 }; fn main() { let mut app = App::new(); app.insert_resource(Msaa { samples: 4 }) + .insert_resource(ClearColor(Color::rgb(0.07, 0.001, 0.02))) .add_plugins(DefaultPlugins) .add_plugin(CyberGeomPlugin) .add_plugin(CyberGlamorPlugin)