Executing a system once during runtime from another system #3112
-
I am currently working on a simple prototype to experiment with Bevy However I am unsure how to do the following: pub fn debug_spawn(input: Res<Input<KeyCode>>) {
if input.just_pressed(KeyCode::O) {
// somehow execute spawn_dummy
}
} And the following system to spawn a dummy player: pub fn spawn_dummy(mut commands: Commands, materials: Res<Materials>, mut c_mat: ResMut<Assets<ColorMaterial>>) {
let mut mat = materials.player_material.clone();
c_mat.get_mut(&mat).unwrap().color = AlignmentColors::Enemy.into();
let sprite = SpriteBundle {
material: mat,
..Default::default()
};
commands.spawn_bundle(sprite).insert_bundle(PlayerBundle {
..Default::default()
});
} How can I make the |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
you're probably looking for events https://bevy-cheatbook.github.io/programming/events.html |
Beta Was this translation helpful? Give feedback.
-
As of 0.12, you probably want One-Shot Systems |
Beta Was this translation helpful? Give feedback.
you're probably looking for events https://bevy-cheatbook.github.io/programming/events.html