I use bevy 0.6 and rapierphysics_2d 0.12.0 I have panic as a result of clearing my scene. I have two functions below::
fn cleanup_player(mut commands: Commands, player_data: Res<PlayerData>, query: Query<Entity>) {
commands
.entity(player_data.player_entity)
.despawn_recursive();
commands
.entity(player_data.camera_entity)
.despawn_recursive();
}
fn cleanup(mut commands: Commands, query: Query<Entity>) {
for entity in query.iter() {
commands.entity(entity).despawn_recursive();
}
}
As you can see they are just despawn created earlier entities. But it causes a panic if I use any of it.
I'm actually trying to invoke them on changing from InGame to MainMenu(by pressing ESC)
impl Plugin for PugPlugin {
fn build(&self, app: &mut App) {
app.add_plugin(RapierPhysicsPlugin::<NoUserData>::default())
.add_system(camera_follow_player.label("Camera system"))
.add_system_set(
SystemSet::on_enter(crate::AppState::InGame)
.with_system(sprite_spawn)
.with_system(spawn_floor),
)
.add_system_set(
SystemSet::on_update(crate::AppState::InGame)
.with_system(check_delete)
.with_system(myphysics::player_jumps.label("Player Jumps System"))
.with_system(myphysics::jump_reset.label("Jump Reset System"))
.with_system(myphysics::player_movement.label("Player Movement System"))
.with_system(death_by_height.label("Death system"))
,
)
.add_system_set(SystemSet::on_exit(AppState::InGame).with_system(cleanup).with_system(cleanup_player))
;
}
}
You can see the system set at the end. So I want to switch to main menu from InGame Set, it's not working.
P.s just clean function is also not working inside a scene even without any transitions to MainMenu or smth. So I can't even just delete any entity from my game.
thread 'Compute Task Pool (0)' panicked at 'Attempting to create an EntityCommands for entity 1v1, which doesn't exist.', /Users/Alexander/.cargo/registry/src/github.com-1ecc6299db9ec823/bevy_rapier2d-0.12.0/src/physics/resources.rs:240:26
So that was a problem with my rapier2d physics plugin!
cargo update -p bevy_rapier2d
update from 0.12.0 to 0.12.1 solved my problem