diff --git a/src/backend/mod.rs b/src/backend/mod.rs index 6eb24ce..893d471 100644 --- a/src/backend/mod.rs +++ b/src/backend/mod.rs @@ -1,4 +1,3 @@ - #[cfg(feature = "rapier")] pub mod rapier; pub use rapier::*; diff --git a/src/backend/rapier/bundle.rs b/src/backend/rapier/bundle.rs index 89a090d..b370096 100644 --- a/src/backend/rapier/bundle.rs +++ b/src/backend/rapier/bundle.rs @@ -1,6 +1,5 @@ - -use bevy::prelude::*; use super::rapier::prelude::*; +use bevy::prelude::*; /// Contains common physics settings for character controllers. #[derive(Bundle)] @@ -35,7 +34,7 @@ impl Default for RapierPhysicsBundle { fn default() -> Self { Self { rigidbody: default(), - collider: Collider::capsule(Vec3::new(0.0, 0.0, 0.0), Vec3::new(0.0, 0.5, 0.0), 0.5), + collider: Collider::capsule(Vec3::new(0.0, 0.0, 0.0), Vec3::new(0.0, 0.5, 0.0), 0.3), velocity: default(), gravity: GravityScale(0.0), sleeping: default(), diff --git a/src/backend/rapier/mod.rs b/src/backend/rapier/mod.rs index 64a9251..4eeb1c4 100644 --- a/src/backend/rapier/mod.rs +++ b/src/backend/rapier/mod.rs @@ -19,8 +19,8 @@ mod mass; pub use mass::get_mass_from_backend; mod velocity; pub use velocity::get_velocity_from_backend; -mod query; mod plugin; +mod query; pub use plugin::WanderlustRapierPlugin; use rapier::prelude::Collider; diff --git a/src/backend/rapier/plugin.rs b/src/backend/rapier/plugin.rs index f651ced..9d0d6c1 100644 --- a/src/backend/rapier/plugin.rs +++ b/src/backend/rapier/plugin.rs @@ -12,9 +12,15 @@ impl Plugin for WanderlustRapierPlugin { app.add_systems(Startup, super::setup_physics_context); } + app.configure_sets( + self.schedule.clone(), + (WanderlustSet::Apply,).before(crate::rapier::PhysicsSet::SyncBackend), + ); + app.add_systems( self.schedule.clone(), ( + super::update_delta_time, super::get_mass_from_backend, super::get_velocity_from_backend, ) diff --git a/src/plugins.rs b/src/plugins.rs index cf1f7ec..c350cc9 100644 --- a/src/plugins.rs +++ b/src/plugins.rs @@ -85,7 +85,7 @@ impl Plugin for WanderlustPlugin { .register_type::() .register_type::>(); - app.insert_resource(PhysicsDeltaTime(0.0)); + app.insert_resource(PhysicsDeltaTime(0.016)); if self.default_system_setup { #[cfg(feature = "rapier")] @@ -94,16 +94,18 @@ impl Plugin for WanderlustPlugin { tweaks: self.tweaks, schedule: self.schedule.clone(), }); - - app.configure_sets( - self.schedule.clone(), - ( - WanderlustSet::Apply, - ) - .before(crate::backend::rapier::backend_label()), - ); }; + app.configure_sets( + self.schedule.clone(), + ( + WanderlustSet::Sync, + WanderlustSet::Compute, + WanderlustSet::Apply, + ) + .chain(), + ); + app.add_systems( self.schedule.clone(), (