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:
parent
93d1db607a
commit
cd16490563
3 changed files with 19 additions and 6 deletions
|
@ -39,6 +39,7 @@ fn setup_colliders(
|
||||||
..Default::default()
|
..Default::default()
|
||||||
}
|
}
|
||||||
.into(),
|
.into(),
|
||||||
|
mass_properties: ColliderMassProps::Density(0.0).into(),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
};
|
};
|
||||||
commands
|
commands
|
||||||
|
@ -47,9 +48,20 @@ fn setup_colliders(
|
||||||
.insert_bundle(pcollide);
|
.insert_bundle(pcollide);
|
||||||
|
|
||||||
let (bike, xform) = bike_query.single();
|
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();
|
let mut bbody = RigidBodyBundle::default();
|
||||||
bbody.damping.angular_damping = 0.7;
|
bbody.damping.angular_damping = 0.5;
|
||||||
bbody.damping.linear_damping = 0.4;
|
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());
|
let isometry = Isometry::from_parts(xform.translation.into(), xform.rotation.into());
|
||||||
bbody.position = isometry.into();
|
bbody.position = isometry.into();
|
||||||
// collider
|
// collider
|
||||||
|
|
|
@ -3,7 +3,7 @@ use bevy::prelude::*;
|
||||||
use crate::Label;
|
use crate::Label;
|
||||||
|
|
||||||
pub const PLANET_RADIUS: f32 = 860.0;
|
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)]
|
#[derive(Component, Debug)]
|
||||||
pub struct CyberBike;
|
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),
|
translation: Vec3::new(SPAWN_ALTITUDE, 0.0, 0.0),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
}
|
}
|
||||||
.looking_at(Vec3::ZERO, Vec3::Y),
|
.looking_at(Vec3::new(PLANET_RADIUS, 1000.0, 0.0), Vec3::X),
|
||||||
GlobalTransform::identity(),
|
GlobalTransform::identity(),
|
||||||
))
|
))
|
||||||
.with_children(|rider| {
|
.with_children(|rider| {
|
||||||
|
|
|
@ -11,13 +11,14 @@ use cyber_rider::{
|
||||||
};
|
};
|
||||||
|
|
||||||
const MOVEMENT_SETTINGS: MovementSettings = MovementSettings {
|
const MOVEMENT_SETTINGS: MovementSettings = MovementSettings {
|
||||||
sensitivity: 50.0, // default: 1.0
|
sensitivity: 10.0, // default: 1.0
|
||||||
accel: 12.0, // default: 40.0
|
accel: 20.0, // default: 40.0
|
||||||
};
|
};
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let mut app = App::new();
|
let mut app = App::new();
|
||||||
app.insert_resource(Msaa { samples: 4 })
|
app.insert_resource(Msaa { samples: 4 })
|
||||||
|
.insert_resource(ClearColor(Color::rgb(0.07, 0.001, 0.02)))
|
||||||
.add_plugins(DefaultPlugins)
|
.add_plugins(DefaultPlugins)
|
||||||
.add_plugin(CyberGeomPlugin)
|
.add_plugin(CyberGeomPlugin)
|
||||||
.add_plugin(CyberGlamorPlugin)
|
.add_plugin(CyberGlamorPlugin)
|
||||||
|
|
Loading…
Reference in a new issue