Just more physics tweaks.

Things are stable and it doesn't get its steering stuck, plus it spawns near the ground.
This commit is contained in:
Joe Ardent 2022-02-13 13:58:49 -08:00
parent 93d1db607a
commit cd16490563
3 changed files with 19 additions and 6 deletions

View file

@ -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

View file

@ -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<AssetServer>) {
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| {

View file

@ -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)