gpt4 book ai didi

bevy - 如何在 bevy 0.5.0 中生成一个实体,该实体是用 commands.spawn_bundle() 生成的

转载 作者:行者123 更新时间:2023-12-04 16:24:48 26 4
gpt4 key购买 nike

这是一个非常简单的问题。
我已经重写了我的代码以处理新版本 bevy 附带的语法和其他更改。
编译时似乎一切正常,除了实体的消失。
我在上述实体中生成,例如:

commands.spawn_bundle(PbrBundle {
mesh: meshes.add(Mesh::from(shape::Cube { size: 1.0 })),
material: builder_texture.clone(),
transform: Transform::from_matrix(Mat4::from_scale_rotation_translation(
Vec3::splat(0.75),
Quat::from_rotation_x(0.0),
Vec3::new(0.0, 0.0, 0.0),
)),
..Default::default()
})
.insert(controll::BuilderIndicator);
但我无法像这样让它消失:
fn despawn(
mut entity: Query<(Entity, controll::BuilderIndicator), With<controll::BuilderIndicator>>,
mut commands: Commands,
) {
for (entity, example) in entity.iter_mut() {
commands.despawn(entity);
}
}
它返回:
error[E0599]: no method named `despawn` found for struct `bevy::prelude::Commands<'_>` in the current scope
--> src/controll.rs:120:26
|
120 | commands.despawn(entity);
| ^^^^^^^ help: there is an associated function with a similar name: `spawn`

error: aborting due to previous error

我该怎么做才能让它发挥作用?

最佳答案

好像有些方法移到了EntityCommands .
所以你必须这样做:commands.entity(entity).despawn();我还没有测试。

关于bevy - 如何在 bevy 0.5.0 中生成一个实体,该实体是用 commands.spawn_bundle() 生成的,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66990382/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com