diff --git a/CHANGELOG.md b/CHANGELOG.md index befabb27..b553961e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,11 +7,10 @@ - `RapierContext` is now a `Component` - Rapier now supports multiple worlds. - Migration guide: - - `ResMut` -> `RapierContextAccessMut` - - `Res` -> `Query<&RapierContext>` - - `ResMut` -> `Query<&mut RapierConfiguration>` - - `Res` -> `Query<&RapierConfiguration>` - - you can reach out for the underlying configuration via .single + - `ResMut` -> `DefaultRapierContextAccessMut` + - `Res` -> `DefaultRapierContextAccess` + - `ResMut` -> `DefaultRapierConfigurationMut` + - `Res` -> `DefaultRapierConfiguration` ## v0.27.0-rc.1 (18 June 2024) diff --git a/bevy_rapier3d/examples/multi_world3.rs b/bevy_rapier3d/examples/multi_world3.rs new file mode 100644 index 00000000..04f6b29c --- /dev/null +++ b/bevy_rapier3d/examples/multi_world3.rs @@ -0,0 +1,117 @@ +use bevy::prelude::*; +use bevy_rapier3d::prelude::*; + +const N_WORLDS: usize = 2; + +fn main() { + App::new() + .insert_resource(ClearColor(Color::rgb( + 0xF9 as f32 / 255.0, + 0xF9 as f32 / 255.0, + 0xFF as f32 / 255.0, + ))) + .add_plugins(( + DefaultPlugins, + RapierPhysicsPlugin::::default().with_default_world(None), + RapierDebugRenderPlugin::default(), + )) + .add_systems( + Startup, + ((create_worlds, setup_physics).chain(), setup_graphics), + ) + .add_systems(Update, move_platforms) + // .add_systems(Update, change_world) + // .add_systems(Update, despawn_last) + .run(); +} + +fn create_worlds(mut commands: Commands) { + for i in 0..N_WORLDS { + commands.spawn((RapierContext::default(), WorldId(i))); + } +} + +fn setup_graphics(mut commands: Commands) { + commands.spawn(Camera3dBundle { + transform: Transform::from_xyz(0.0, 3.0, -10.0) + .looking_at(Vec3::new(0.0, 0.0, 0.0), Vec3::Y), + ..Default::default() + }); +} + +#[derive(Component)] +pub struct WorldId(pub usize); + +#[derive(Component)] +struct Platform { + starting_y: f32, +} + +fn move_platforms(time: Res