Closed
Description
Currently, the implementation requires that the component being spawned implemented DynamicBundle, so you can't do something like this:
fn setup(
mut commands: Commands,
) {
commands
// Player
.spawn(SpriteComponents {
material: materials.add(Color::rgb(0.5, 0.0, 0.0).into()),
translation: Translation(Vec3::new(window_desc.width as f32 / 2.0, 50.0, 0.0)),
sprite: Sprite {
size: Vec2::new(30.0, 30.0),
},
..Default::default()
})
.with(Player::new())
.with_children(|parent| {
parent.spawn(BulletEmitter::new());
});
}
Instead, you need to do it that way:
.with_children(|parent| {
parent.spawn( (BulletEmitter::new(), ) );
});
}
While this is a decent workaround, could it be possible to make it so you can use a regular Component too?
A friend suggested implementing the following, although I'm not knowledgeable about Rust enough to do so myself:
DynamicBundle for T: Component
Thanks!