The function checks if the montage is transient when a slot name is provided. Why is this so?
UAnimMontage* CurMontage = MontageInstance->Montage;
if (CurMontage && CurMontage->GetOuter() == GetTransientPackage())
{
// Check each track, in practice there should only be one on these
for (int32 SlotTrackIndex = 0; SlotTrackIndex < CurMontage->SlotAnimTracks.Num(); SlotTrackIndex++)
{
const FSlotAnimationTrack* AnimTrack = &CurMontage->SlotAnimTracks[SlotTrackIndex];
if (AnimTrack && AnimTrack->SlotName == SlotNodeName)
{
// Found it
MontageInstance->Stop(FAlphaBlend(InBlendOutTime));
break;
}
}
}