diff --git a/src/plugin/plugin.rs b/src/plugin/plugin.rs index 94a89643c..8933a7c83 100644 --- a/src/plugin/plugin.rs +++ b/src/plugin/plugin.rs @@ -99,7 +99,7 @@ where match set { PhysicsSet::SyncBackend => ( // Run the character controller before the manual transform propagation. - systems::update_character_controls, + systems::update_character_controls.in_set(PhysicsSet::SyncBackend), // Run Bevy transform propagation additionally to sync [`GlobalTransform`] ( bevy::transform::systems::sync_simple_transforms, @@ -107,30 +107,38 @@ where ) .chain() .in_set(RapierTransformPropagateSet), - systems::on_add_entity_with_parent, - systems::on_change_world, - systems::sync_removals, - #[cfg(all(feature = "dim3", feature = "async-collider"))] - systems::init_async_scene_colliders, - #[cfg(all(feature = "dim3", feature = "async-collider"))] - systems::init_async_colliders, - systems::init_rigid_bodies, - systems::init_colliders, - systems::init_joints, - systems::apply_scale, - systems::apply_collider_user_changes, - systems::apply_rigid_body_user_changes, - systems::apply_joint_user_changes, - systems::apply_initial_rigid_body_impulses, + ( + systems::on_add_entity_with_parent, + systems::on_change_world, + systems::sync_removals, + #[cfg(all(feature = "dim3", feature = "async-collider"))] + systems::init_async_scene_colliders, + #[cfg(all(feature = "dim3", feature = "async-collider"))] + systems::init_async_colliders, + systems::init_rigid_bodies, + systems::init_colliders, + systems::init_joints, + systems::apply_scale, + systems::apply_collider_user_changes, + systems::apply_rigid_body_user_changes, + systems::apply_joint_user_changes, + systems::apply_initial_rigid_body_impulses, + ) + .chain() + .in_set(PhysicsSet::SyncBackend), ) .chain() .into_configs(), - PhysicsSet::StepSimulation => (systems::step_simulation::).into_configs(), + PhysicsSet::StepSimulation => (systems::step_simulation::) + .in_set(PhysicsSet::StepSimulation) + .into_configs(), PhysicsSet::Writeback => ( systems::update_colliding_entities, systems::writeback_rigid_bodies, - systems::writeback_mass_properties, + // Each writeback write to different properties. + systems::writeback_mass_properties.ambiguous_with(systems::writeback_rigid_bodies), ) + .in_set(PhysicsSet::Writeback) .into_configs(), } } @@ -244,14 +252,17 @@ where .chain() .before(TransformSystem::TransformPropagate), ); + app.configure_sets( + self.schedule, + RapierTransformPropagateSet.in_set(PhysicsSet::SyncBackend), + ); app.add_systems( self.schedule, ( - Self::get_systems(PhysicsSet::SyncBackend).in_set(PhysicsSet::SyncBackend), - Self::get_systems(PhysicsSet::StepSimulation) - .in_set(PhysicsSet::StepSimulation), - Self::get_systems(PhysicsSet::Writeback).in_set(PhysicsSet::Writeback), + Self::get_systems(PhysicsSet::SyncBackend), + Self::get_systems(PhysicsSet::StepSimulation), + Self::get_systems(PhysicsSet::Writeback), ), ); app.init_resource::();