fucked up

This commit is contained in:
Joe Ardent 2023-02-22 22:39:48 -08:00
parent 4e6fab5952
commit 031d4815e2
6 changed files with 18 additions and 16 deletions

View File

@ -46,14 +46,12 @@ impl Default for Tunneling {
pub struct MovementSettings { pub struct MovementSettings {
pub accel: f32, pub accel: f32,
pub gravity: f32, pub gravity: f32,
pub sensitivity: f32,
} }
impl Default for MovementSettings { impl Default for MovementSettings {
fn default() -> Self { fn default() -> Self {
Self { Self {
sensitivity: 6.0, accel: 20.0,
accel: 40.0,
gravity: 9.8, gravity: 9.8,
} }
} }

View File

@ -28,6 +28,7 @@ impl Plugin for CyberActionPlugin {
.register_type::<CyberLean>() .register_type::<CyberLean>()
.register_type::<CatControllerSettings>() .register_type::<CatControllerSettings>()
.add_plugin(RapierPhysicsPlugin::<NoUserData>::default()) .add_plugin(RapierPhysicsPlugin::<NoUserData>::default())
.add_startup_system(timestep_setup)
.add_plugin(FrameTimeDiagnosticsPlugin::default()) .add_plugin(FrameTimeDiagnosticsPlugin::default())
.add_system(surface_fix.label("surface_fix")) .add_system(surface_fix.label("surface_fix"))
.add_system(gravity.label("gravity").before("cat")) .add_system(gravity.label("gravity").before("cat"))

View File

@ -5,7 +5,7 @@ use bevy::prelude::{
}; };
use bevy_rapier3d::prelude::{ use bevy_rapier3d::prelude::{
CollisionGroups, ExternalForce, Group, MultibodyJoint, QueryFilter, RapierConfiguration, CollisionGroups, ExternalForce, Group, MultibodyJoint, QueryFilter, RapierConfiguration,
RapierContext, ReadMassProperties, Velocity, RapierContext, ReadMassProperties, TimestepMode, Velocity,
}; };
#[cfg(feature = "inspector")] #[cfg(feature = "inspector")]
@ -36,6 +36,15 @@ fn rotate_point(pt: &Vec3, rot: &Quat) -> Vec3 {
-Vec3::from_array([rot_qpt.x, rot_qpt.y, rot_qpt.z]) -Vec3::from_array([rot_qpt.x, rot_qpt.y, rot_qpt.z])
} }
pub(super) fn timestep_setup(mut config: ResMut<RapierConfiguration>) {
let ts = TimestepMode::Interpolated {
dt: 1.0 / 55.0,
time_scale: 1.0,
substeps: 16,
};
config.timestep_mode = ts;
}
/// The gravity vector points from the cyberbike to the center of the planet. /// The gravity vector points from the cyberbike to the center of the planet.
pub(super) fn gravity( pub(super) fn gravity(
mut query: Query<(&Transform, &mut ExternalForce), With<CyberBikeBody>>, mut query: Query<(&Transform, &mut ExternalForce), With<CyberBikeBody>>,

View File

@ -55,7 +55,7 @@ pub(super) fn spawn_cyberbike(
.spawn(RigidBody::Dynamic) .spawn(RigidBody::Dynamic)
.insert(spatialbundle) .insert(spatialbundle)
.insert(( .insert((
Collider::capsule(Vec3::new(0.0, 0.0, -0.65), Vec3::new(0.0, 0.0, 0.8), 0.40), Collider::capsule(Vec3::new(0.0, 0.0, -0.65), Vec3::new(0.0, 0.0, 0.8), 0.5),
bike_collision_group, bike_collision_group,
mass_properties, mass_properties,
damping, damping,

View File

@ -38,7 +38,7 @@ impl Default for WheelConfig {
stiffness: 50.0, stiffness: 50.0,
damping: 8.0, damping: 8.0,
radius: 0.3, radius: 0.3,
thickness: 0.06, thickness: 0.2,
friction: 1.2, friction: 1.2,
restitution: 0.8, restitution: 0.8,
density: 0.6, density: 0.6,

View File

@ -76,14 +76,8 @@ pub fn spawn_tires(
linear_damping: 0.8, linear_damping: 0.8,
..Default::default() ..Default::default()
}; };
let mesh = Mesh::from(tire);
let mut idxs = Vec::new();
let indices = mesh.indices().unwrap().iter().collect::<Vec<_>>();
for idx in indices.as_slice().chunks_exact(3) {
idxs.push([idx[0] as u32, idx[1] as u32, idx[2] as u32]);
}
let wheel_collider = Collider::round_cylinder(tire_thickness, wheel_rad, tire_thickness); let wheel_collider = Collider::ball(wheel_rad);
let mass_props = ColliderMassProperties::Density(conf.density); let mass_props = ColliderMassProperties::Density(conf.density);
let damping = conf.damping; let damping = conf.damping;
@ -119,11 +113,11 @@ pub fn spawn_tires(
fork_rb_entity fork_rb_entity
}; };
let axel_builder = RevoluteJointBuilder::new(Vec3::Y); let axel_builder = RevoluteJointBuilder::new(Vec3::X);
let mut axel_joint = MultibodyJoint::new(axel_parent_entity, axel_builder); let mut axel_joint = MultibodyJoint::new(axel_parent_entity, axel_builder);
// re-orient the joint so that the wheel is correctly oriented // re-orient the joint so that the wheel is correctly oriented
let real_axel = *axel_joint.data.set_local_axis1(Vec3::X); //let real_axel = *axel_joint.data.set_local_axis1(Vec3::X);
axel_joint.data = real_axel; //axel_joint.data = real_axel;
commands.spawn(pbr_bundle.clone()).insert(( commands.spawn(pbr_bundle.clone()).insert((
wheel_collider, wheel_collider,