From f3082ffe1e92e52b681a28269b241c5762a1eda6 Mon Sep 17 00:00:00 2001 From: robtfm <50659922+robtfm@users.noreply.github.com> Date: Thu, 15 Aug 2024 17:34:29 +0100 Subject: [PATCH] animator play/start (14546) --- crates/bevy_animation/src/lib.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/crates/bevy_animation/src/lib.rs b/crates/bevy_animation/src/lib.rs index b1d305c7cc044..5ea16d89af2d3 100755 --- a/crates/bevy_animation/src/lib.rs +++ b/crates/bevy_animation/src/lib.rs @@ -586,14 +586,14 @@ thread_local! { impl AnimationPlayer { /// Start playing an animation, restarting it if necessary. pub fn start(&mut self, animation: AnimationNodeIndex) -> &mut ActiveAnimation { - self.active_animations.entry(animation).or_default() + let playing_animation = self.active_animations.entry(animation).or_default(); + playing_animation.replay(); + playing_animation } /// Start playing an animation, unless the requested animation is already playing. pub fn play(&mut self, animation: AnimationNodeIndex) -> &mut ActiveAnimation { - let playing_animation = self.active_animations.entry(animation).or_default(); - playing_animation.weight = 1.0; - playing_animation + self.active_animations.entry(animation).or_default() } /// Stops playing the given animation, removing it from the list of playing