Add slot stop methods without anim param.

This commit is contained in:
Chandler Cox
2025-11-23 14:19:37 -06:00
parent f8dc8ab903
commit 2d56411e5f
2 changed files with 36 additions and 0 deletions

View File

@@ -563,6 +563,20 @@ void AnimatedModel::StopSlotAnimation(const StringView& slotName, Animation* ani
}
}
void AnimatedModel::StopSlotAnimation(const StringView& slotName)
{
for (auto& slot : GraphInstance.Slots)
{
if (slot.Name == slotName)
{
//slot.Animation = nullptr; // TODO: make an immediate version of this method and set the animation to nullptr.
if (slot.Animation != nullptr)
slot.Reset = true;
break;
}
}
}
void AnimatedModel::PauseSlotAnimation()
{
for (auto& slot : GraphInstance.Slots)
@@ -601,6 +615,16 @@ bool AnimatedModel::IsPlayingSlotAnimation(const StringView& slotName, Animation
return false;
}
bool AnimatedModel::IsPlayingSlotAnimation(const StringView& slotName)
{
for (auto& slot : GraphInstance.Slots)
{
if (slot.Name == slotName && !slot.Pause)
return true;
}
return false;
}
void AnimatedModel::ApplyRootMotion(const Transform& rootMotionDelta)
{
// Skip if no motion

View File

@@ -414,6 +414,12 @@ public:
/// <param name="slotName">The name of the slot.</param>
/// <param name="anim">The animation to stop.</param>
API_FUNCTION() void StopSlotAnimation(const StringView& slotName, Animation* anim);
/// <summary>
/// Stops the animation playback on the slot in Anim Graph.
/// </summary>
/// <param name="slotName">The name of the slot.</param>
API_FUNCTION() void StopSlotAnimation(const StringView& slotName);
/// <summary>
/// Pauses all the animations playback on the all slots in Anim Graph.
@@ -439,6 +445,12 @@ public:
/// <param name="anim">The animation to check.</param>
API_FUNCTION() bool IsPlayingSlotAnimation(const StringView& slotName, Animation* anim);
/// <summary>
/// Checks if the animation playback is active on the slot in Anim Graph (not paused).
/// </summary>
/// <param name="slotName">The name of the slot.</param>
API_FUNCTION() bool IsPlayingSlotAnimation(const StringView& slotName);
private:
void ApplyRootMotion(const Transform& rootMotionDelta);
void SyncParameters();