Bevyengine 消失时出现恐慌

发布于 2025-01-09 12:15:41 字数 2251 浏览 4 评论 0原文

我使用 bevy 0.6 和 rapierphysicals_2d 0.12.0 清理现场后我感到恐慌。我有以下两个函数::

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();
  }
}

如您所见,它们只是消失之前创建的实体。但如果我使用其中任何一个,都会引起恐慌。

我实际上试图在从 InGame 更改为 MainMenu 时调用它们(通过按 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))
            ;
    }
}

您可以在最后看到系统设置。所以我想从 InGame Set 切换到主菜单,但它不起作用。

即使没有任何到 MainMenu 或其他的转换,只是清理功能也无法在场景内工作。所以我什至不能从我的游戏中删除任何实体。

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

https://github.com/asinchenko/NamiWorld

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

https://github.com/asinchenko/NamiWorld

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

妄司 2025-01-16 12:15:42

所以这是我的 rapier2d 物理插件的问题!

cargo update -p bevy_rapier2d

从 0.12.0 更新到 0.12.1 解决了我的问题

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文