diff --git a/Source/Engine/Animations/Graph/AnimGraph.h b/Source/Engine/Animations/Graph/AnimGraph.h index afaa4441b..30ac5a776 100644 --- a/Source/Engine/Animations/Graph/AnimGraph.h +++ b/Source/Engine/Animations/Graph/AnimGraph.h @@ -197,6 +197,7 @@ struct FLAXENGINE_API AnimGraphSlot float BlendOutTime = 0.0f; int32 LoopCount = 0; bool Pause = false; + bool Reset = false; }; /// diff --git a/Source/Engine/Animations/Graph/AnimGroup.Animation.cpp b/Source/Engine/Animations/Graph/AnimGroup.Animation.cpp index 1058ea301..fc7cf6dbc 100644 --- a/Source/Engine/Animations/Graph/AnimGroup.Animation.cpp +++ b/Source/Engine/Animations/Graph/AnimGroup.Animation.cpp @@ -2098,6 +2098,12 @@ void AnimGraphExecutor::ProcessGroupAnimation(Box* boxBase, Node* nodeBase, Valu auto& slot = slots[bucket.Index]; Animation* anim = slot.Animation; ASSERT(slot.Animation && slot.Animation->IsLoaded()); + if (slot.Reset) + { + // Start from the begining + slot.Reset = false; + bucket.TimePosition = 0.0f; + } const float deltaTime = slot.Pause ? 0.0f : context.DeltaTime * slot.Speed; const float length = anim->GetLength(); const bool loop = bucket.LoopsLeft != 0; diff --git a/Source/Engine/Level/Actors/AnimatedModel.cpp b/Source/Engine/Level/Actors/AnimatedModel.cpp index c1b5af398..17f117173 100644 --- a/Source/Engine/Level/Actors/AnimatedModel.cpp +++ b/Source/Engine/Level/Actors/AnimatedModel.cpp @@ -494,6 +494,7 @@ void AnimatedModel::StopSlotAnimation(const StringView& slotName, Animation* ani if (slot.Animation == anim && slot.Name == slotName) { slot.Animation = nullptr; + slot.Reset = true; break; } }