Compare commits

...

2 commits

Author SHA1 Message Date
Joe Ardent
e358830c5f no colliders for wheels 2024-06-15 18:54:41 -07:00
Joe Ardent
8a440d6e81 add prev vel to body 2024-06-15 15:55:55 -07:00
5 changed files with 15 additions and 33 deletions

View file

@ -38,7 +38,7 @@ impl Plugin for CyberActionPlugin {
reset_wheel_forces,
cyber_lean,
falling_cat,
input_forces,
wheel_forces,
drag,
)
.chain(),

View file

@ -137,7 +137,7 @@ pub(super) fn wheel_forces(
&mut PreviousVelocity,
Option<&CyberSteering>,
),
With<CyberWheel>,
(With<CyberWheel>, Without<CyberBikeBody>),
>,
mut body_query: Query<
(
@ -146,7 +146,7 @@ pub(super) fn wheel_forces(
&mut PreviousVelocity,
&ReadMassProperties,
),
With<CyberBikeBody>,
(With<CyberBikeBody>, Without<CyberWheel>),
>,
wheel_config: Res<WheelConfig>,
rapier_config: Res<RapierConfiguration>,

View file

@ -8,7 +8,10 @@ use bevy_rapier3d::prelude::{
};
use super::{spawn_wheels, CyberBikeBody, Meshterial, WheelConfig, BIKE_BODY_COLLISION_GROUP};
use crate::{action::CatControllerState, planet::PLANET_RADIUS};
use crate::{
action::{CatControllerState, PreviousVelocity},
planet::PLANET_RADIUS,
};
pub(super) fn spawn_cyberbike(
mut commands: Commands,
@ -63,6 +66,7 @@ pub(super) fn spawn_cyberbike(
Sleeping::disabled(),
Ccd { enabled: true },
ReadMassProperties::default(),
PreviousVelocity::default(),
))
.insert(TransformInterpolation {
start: None,

View file

@ -2,13 +2,12 @@ use bevy::prelude::*;
use bevy_rapier3d::{
dynamics::{FixedJointBuilder, Velocity},
prelude::{
Ccd, CoefficientCombineRule, Collider, ColliderMassProperties, CollisionGroups, Damping,
ExternalForce, Friction, MultibodyJoint, PrismaticJointBuilder, Restitution,
RevoluteJointBuilder, RigidBody, Sleeping, TransformInterpolation,
ColliderMassProperties, ExternalForce, MultibodyJoint, PrismaticJointBuilder, RigidBody,
Sleeping, TransformInterpolation,
},
};
use super::{CyberSteering, CyberWheel, Meshterial, WheelConfig, BIKE_WHEEL_COLLISION_GROUP};
use super::{CyberSteering, CyberWheel, Meshterial, WheelConfig};
use crate::action::PreviousVelocity;
pub(crate) fn spawn_wheels(
@ -17,21 +16,13 @@ pub(crate) fn spawn_wheels(
conf: &WheelConfig,
meshterials: &mut Meshterial,
) {
let (membership, filter) = BIKE_WHEEL_COLLISION_GROUP;
let wheels_collision_group = CollisionGroups::new(membership, filter);
let wheel_y = conf.y;
let stiffness = conf.stiffness;
let not_sleeping = Sleeping::disabled();
let ccd = Ccd { enabled: true };
let limits = conf.limits;
let (meshes, materials) = meshterials;
let rake_vec: Vec3 = Vec3::new(0.0, 1.0, 0.57).normalize(); // about 30 degrees of rake
let friction = Friction {
coefficient: conf.friction,
combine_rule: CoefficientCombineRule::Min,
};
let mut wheel_poses = Vec::with_capacity(2);
// front
@ -51,7 +42,7 @@ pub(crate) fn spawn_wheels(
}
for (offset, steering) in wheel_poses {
let (mesh, collider) = gen_tires(conf);
let mesh = gen_tires(conf);
let material = StandardMaterial {
base_color: Color::YELLOW,
@ -93,7 +84,6 @@ pub(crate) fn spawn_wheels(
.spawn(RigidBody::Dynamic)
.insert(neck_joint)
.insert(steering)
.insert(not_sleeping)
.id();
neck
} else {
@ -104,15 +94,11 @@ pub(crate) fn spawn_wheels(
let axel_joint = MultibodyJoint::new(axel_parent_entity, axel_builder);
commands.spawn(pbr_bundle).insert((
collider,
mass_props,
//wheel_damping,
ccd,
not_sleeping,
axel_joint,
wheels_collision_group,
friction,
CyberWheel,
not_sleeping,
Velocity::default(),
PreviousVelocity::default(),
ExternalForce::default(),
@ -124,11 +110,8 @@ pub(crate) fn spawn_wheels(
}
// do mesh shit
fn gen_tires(conf: &WheelConfig) -> (Mesh, Collider) {
fn gen_tires(conf: &WheelConfig) -> Mesh {
let wheel_rad = conf.radius;
let tire = Sphere::new(wheel_rad);
let mesh = Mesh::from(tire);
let wheel_collider = Collider::ball(wheel_rad);
(mesh, wheel_collider)
Mesh::from(tire)
}

View file

@ -5,8 +5,6 @@ use bevy::{
TextBundle, TextSection, TextStyle, Transform, With,
},
};
//#[cfg(feature = "inspector")]
//use bevy_inspector_egui::quick::WorldInspectorPlugin;
use bevy_rapier3d::prelude::Velocity;
use crate::bike::CyberBikeBody;
@ -53,9 +51,6 @@ pub struct CyberUIPlugin;
impl Plugin for CyberUIPlugin {
fn build(&self, app: &mut App) {
#[cfg(feature = "inspector")]
//app.add_plugins(WorldInspectorPlugin::new());
//
app.add_systems(Startup, setup_ui)
.add_systems(Update, update_ui);