diff --git a/bevy_rapier3d/examples/multi_world3.rs b/bevy_rapier3d/examples/multi_world3.rs index 04f6b29c..65e448cb 100644 --- a/bevy_rapier3d/examples/multi_world3.rs +++ b/bevy_rapier3d/examples/multi_world3.rs @@ -1,18 +1,19 @@ -use bevy::prelude::*; +use bevy::{input::common_conditions::input_just_pressed, prelude::*}; use bevy_rapier3d::prelude::*; const N_WORLDS: usize = 2; fn main() { App::new() - .insert_resource(ClearColor(Color::rgb( + .insert_resource(ClearColor(Color::srgb( 0xF9 as f32 / 255.0, 0xF9 as f32 / 255.0, 0xFF as f32 / 255.0, ))) .add_plugins(( DefaultPlugins, - RapierPhysicsPlugin::::default().with_default_world(None), + RapierPhysicsPlugin::::default() + .with_default_world(RapierContextInitialization::NoAutomaticRapierContext), RapierDebugRenderPlugin::default(), )) .add_systems( @@ -20,14 +21,19 @@ fn main() { ((create_worlds, setup_physics).chain(), setup_graphics), ) .add_systems(Update, move_platforms) - // .add_systems(Update, change_world) - // .add_systems(Update, despawn_last) + .add_systems( + Update, + change_world.run_if(input_just_pressed(KeyCode::KeyC)), + ) .run(); } fn create_worlds(mut commands: Commands) { for i in 0..N_WORLDS { - commands.spawn((RapierContext::default(), WorldId(i))); + let mut world = commands.spawn((RapierContext::default(), WorldId(i))); + if i == 0 { + world.insert(DefaultRapierContext); + } } } @@ -53,23 +59,20 @@ fn move_platforms(time: Res