still gets unstable
This commit is contained in:
parent
708b518047
commit
2db6041774
5 changed files with 36 additions and 31 deletions
|
@ -49,8 +49,18 @@ pub(super) fn gravity(
|
|||
mut query: Query<(&Transform, &mut ExternalForce), With<CyberBikeBody>>,
|
||||
settings: Res<MovementSettings>,
|
||||
mut rapier_config: ResMut<RapierConfiguration>,
|
||||
#[cfg(feature = "inspector")] mut debug_instant: ResMut<ActionDebugInstant>,
|
||||
) {
|
||||
let (xform, mut forces) = query.single_mut();
|
||||
|
||||
#[cfg(feature = "inspector")]
|
||||
{
|
||||
if debug_instant.elapsed().as_millis() > 1000 {
|
||||
dbg!(&forces);
|
||||
debug_instant.reset();
|
||||
}
|
||||
}
|
||||
|
||||
rapier_config.gravity = xform.translation.normalize() * -settings.gravity;
|
||||
forces.force = Vec3::ZERO;
|
||||
forces.torque = Vec3::ZERO;
|
||||
|
@ -88,7 +98,6 @@ pub(super) fn falling_cat(
|
|||
time: Res<Time>,
|
||||
settings: Res<CatControllerSettings>,
|
||||
lean: Res<CyberLean>,
|
||||
#[cfg(feature = "inspector")] mut debug_instant: ResMut<ActionDebugInstant>,
|
||||
) {
|
||||
let (xform, mut forces, mut control_vars) = bike_query.single_mut();
|
||||
let world_up = xform.translation.normalize();
|
||||
|
@ -108,13 +117,6 @@ pub(super) fn falling_cat(
|
|||
if mag.is_finite() {
|
||||
forces.torque += xform.back() * mag;
|
||||
}
|
||||
#[cfg(feature = "inspector")]
|
||||
{
|
||||
if debug_instant.elapsed().as_millis() > 1000 {
|
||||
dbg!(&control_vars, mag, &target_up);
|
||||
debug_instant.reset();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@ pub(super) fn spawn_cyberbike(
|
|||
wheel_conf: Res<WheelConfig>,
|
||||
mut meshterials: Meshterial,
|
||||
) {
|
||||
let altitude = PLANET_RADIUS - 180.0;
|
||||
let altitude = PLANET_RADIUS - 10.0;
|
||||
|
||||
let mut xform = Transform::from_translation(Vec3::X * altitude)
|
||||
.with_rotation(Quat::from_axis_angle(Vec3::Z, -89.0f32.to_radians()));
|
||||
|
|
|
@ -37,11 +37,11 @@ impl Default for WheelConfig {
|
|||
limits: [-0.5, 0.1],
|
||||
stiffness: 50.0,
|
||||
damping: 8.0,
|
||||
radius: 0.3,
|
||||
radius: 0.38,
|
||||
thickness: 0.2,
|
||||
friction: 1.2,
|
||||
restitution: 0.8,
|
||||
density: 0.6,
|
||||
restitution: 0.95,
|
||||
density: 0.9,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@ pub fn spawn_tires(
|
|||
let wheels_collision_group = CollisionGroups::new(membership, filter);
|
||||
let wheel_y = conf.y;
|
||||
let wheel_rad = conf.radius;
|
||||
let tire_thickness = conf.thickness;
|
||||
let _tire_thickness = conf.thickness;
|
||||
let stiffness = conf.stiffness;
|
||||
let not_sleeping = Sleeping::disabled();
|
||||
let ccd = Ccd { enabled: true };
|
||||
|
@ -100,7 +100,7 @@ pub fn spawn_tires(
|
|||
|
||||
let axel_parent_entity = if let Some(steering) = steering {
|
||||
let neck_builder =
|
||||
RevoluteJointBuilder::new(rake_vec).local_anchor1(Vec3::new(0.0, 0.0, 0.1)); // this adds another 0.1m of trail
|
||||
RevoluteJointBuilder::new(rake_vec).local_anchor1(Vec3::new(0.0, -0.08, 0.1)); // this adds another 0.1m of trail
|
||||
let neck_joint = MultibodyJoint::new(fork_rb_entity, neck_builder);
|
||||
let neck = commands
|
||||
.spawn(RigidBody::Dynamic)
|
||||
|
@ -114,25 +114,28 @@ pub fn spawn_tires(
|
|||
};
|
||||
|
||||
let axel_builder = RevoluteJointBuilder::new(Vec3::X);
|
||||
let mut axel_joint = MultibodyJoint::new(axel_parent_entity, axel_builder);
|
||||
let axel_joint = MultibodyJoint::new(axel_parent_entity, axel_builder);
|
||||
// re-orient the joint so that the wheel is correctly oriented
|
||||
//let real_axel = *axel_joint.data.set_local_axis1(Vec3::X);
|
||||
//axel_joint.data = real_axel;
|
||||
|
||||
commands.spawn(pbr_bundle.clone()).insert((
|
||||
wheel_collider,
|
||||
mass_props,
|
||||
wheel_damping,
|
||||
ccd,
|
||||
not_sleeping,
|
||||
axel_joint,
|
||||
wheels_collision_group,
|
||||
friction,
|
||||
CyberWheel,
|
||||
ExternalForce::default(),
|
||||
Restitution::new(conf.restitution),
|
||||
TransformInterpolation::default(),
|
||||
RigidBody::Dynamic,
|
||||
));
|
||||
commands
|
||||
.spawn(pbr_bundle.clone())
|
||||
.insert((
|
||||
wheel_collider,
|
||||
mass_props,
|
||||
wheel_damping,
|
||||
ccd,
|
||||
not_sleeping,
|
||||
axel_joint,
|
||||
wheels_collision_group,
|
||||
friction,
|
||||
CyberWheel,
|
||||
ExternalForce::default(),
|
||||
Restitution::new(conf.restitution),
|
||||
TransformInterpolation::default(),
|
||||
RigidBody::Dynamic,
|
||||
))
|
||||
.insert(SpatialBundle::default());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,7 +9,7 @@ use wgpu::PrimitiveTopology;
|
|||
|
||||
use crate::Label;
|
||||
|
||||
pub const PLANET_RADIUS: f32 = 6000.0;
|
||||
pub const PLANET_RADIUS: f32 = 3_000.0;
|
||||
|
||||
#[derive(Component)]
|
||||
pub struct CyberPlanet;
|
||||
|
|
Loading…
Reference in a new issue