diff --git a/examples/animation/animated_fox.rs b/examples/animation/animated_fox.rs index 39e66ec9a2fd4..0052cbce75a9a 100644 --- a/examples/animation/animated_fox.rs +++ b/examples/animation/animated_fox.rs @@ -83,24 +83,20 @@ fn setup( // Once the scene is loaded, start the animation fn setup_scene_once_loaded( animations: Res, - mut player: Query<&mut AnimationPlayer>, - mut done: Local, + mut players: Query<&mut AnimationPlayer, Added>, ) { - if !*done { - if let Ok(mut player) = player.get_single_mut() { - player.play(animations.0[0].clone_weak()).repeat(); - *done = true; - } + for mut player in &mut players { + player.play(animations.0[0].clone_weak()).repeat(); } } fn keyboard_animation_control( keyboard_input: Res>, - mut animation_player: Query<&mut AnimationPlayer>, + mut animation_players: Query<&mut AnimationPlayer>, animations: Res, mut current_animation: Local, ) { - if let Ok(mut player) = animation_player.get_single_mut() { + for mut player in &mut animation_players { if keyboard_input.just_pressed(KeyCode::Space) { if player.is_paused() { player.resume();