fucked up
This commit is contained in:
parent
4e6fab5952
commit
031d4815e2
6 changed files with 18 additions and 16 deletions
|
@ -46,14 +46,12 @@ impl Default for Tunneling {
|
|||
pub struct MovementSettings {
|
||||
pub accel: f32,
|
||||
pub gravity: f32,
|
||||
pub sensitivity: f32,
|
||||
}
|
||||
|
||||
impl Default for MovementSettings {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
sensitivity: 6.0,
|
||||
accel: 40.0,
|
||||
accel: 20.0,
|
||||
gravity: 9.8,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,6 +28,7 @@ impl Plugin for CyberActionPlugin {
|
|||
.register_type::<CyberLean>()
|
||||
.register_type::<CatControllerSettings>()
|
||||
.add_plugin(RapierPhysicsPlugin::<NoUserData>::default())
|
||||
.add_startup_system(timestep_setup)
|
||||
.add_plugin(FrameTimeDiagnosticsPlugin::default())
|
||||
.add_system(surface_fix.label("surface_fix"))
|
||||
.add_system(gravity.label("gravity").before("cat"))
|
||||
|
|
|
@ -5,7 +5,7 @@ use bevy::prelude::{
|
|||
};
|
||||
use bevy_rapier3d::prelude::{
|
||||
CollisionGroups, ExternalForce, Group, MultibodyJoint, QueryFilter, RapierConfiguration,
|
||||
RapierContext, ReadMassProperties, Velocity,
|
||||
RapierContext, ReadMassProperties, TimestepMode, Velocity,
|
||||
};
|
||||
|
||||
#[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])
|
||||
}
|
||||
|
||||
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.
|
||||
pub(super) fn gravity(
|
||||
mut query: Query<(&Transform, &mut ExternalForce), With<CyberBikeBody>>,
|
||||
|
|
|
@ -55,7 +55,7 @@ pub(super) fn spawn_cyberbike(
|
|||
.spawn(RigidBody::Dynamic)
|
||||
.insert(spatialbundle)
|
||||
.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,
|
||||
mass_properties,
|
||||
damping,
|
||||
|
|
|
@ -38,7 +38,7 @@ impl Default for WheelConfig {
|
|||
stiffness: 50.0,
|
||||
damping: 8.0,
|
||||
radius: 0.3,
|
||||
thickness: 0.06,
|
||||
thickness: 0.2,
|
||||
friction: 1.2,
|
||||
restitution: 0.8,
|
||||
density: 0.6,
|
||||
|
|
|
@ -76,14 +76,8 @@ pub fn spawn_tires(
|
|||
linear_damping: 0.8,
|
||||
..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 damping = conf.damping;
|
||||
|
||||
|
@ -119,11 +113,11 @@ pub fn spawn_tires(
|
|||
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);
|
||||
// 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;
|
||||
//let real_axel = *axel_joint.data.set_local_axis1(Vec3::X);
|
||||
//axel_joint.data = real_axel;
|
||||
|
||||
commands.spawn(pbr_bundle.clone()).insert((
|
||||
wheel_collider,
|
||||
|
|
Loading…
Reference in a new issue