Bevyengine 消失时出现恐慌
我使用 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
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
所以这是我的 rapier2d 物理插件的问题!
从 0.12.0 更新到 0.12.1 解决了我的问题
So that was a problem with my rapier2d physics plugin!
update from 0.12.0 to 0.12.1 solved my problem