UAnimInstance::Montage_SetEndDelegate
#include "Animation/AnimInstance.h"
Access: public
Specifiers: ENGINE_API
Description
Binds a delegate that fires when a montage finishes playing and its instance is fully stopped. Use this to trigger logic exactly once after a montage has completely ended rather than when it begins blending out.
Caveats & Gotchas
- • The delegate fires after the montage instance is destroyed, so calling Montage_GetCurrentSection or querying montage state inside the callback will return invalid results — cache any needed state before the delegate fires.
- • If you pass nullptr for Montage, the delegate attaches to the topmost active montage instance at call time. If no montage is currently playing the call is a no-op and the delegate is silently discarded.
- • Unlike Montage_SetBlendingOutDelegate, this fires only once the blend-out has fully completed, so there can be a noticeable delay after the visible animation has finished.
Signature
ENGINE_API void Montage_SetEndDelegate(FOnMontageEnded& InOnMontageEnded, UAnimMontage* Montage = nullptr); Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| InOnMontageEnded | FOnMontageEnded& | The delegate to bind; called when the specified montage fully ends (not when blending out starts). | — |
| Montage | UAnimMontage* | The montage to attach the delegate to. If null, binds to the most recently played montage instance. | nullptr |
Return Type
void Example
Trigger logic when an attack montage ends C++
void AMyCharacter::PlayAttackMontage()
{
float Duration = AnimInstance->Montage_Play(AttackMontage);
if (Duration > 0.f)
{
FOnMontageEnded EndDelegate;
EndDelegate.BindUObject(this, &AMyCharacter::OnAttackMontageEnded);
AnimInstance->Montage_SetEndDelegate(EndDelegate, AttackMontage);
}
}
void AMyCharacter::OnAttackMontageEnded(UAnimMontage* Montage, bool bInterrupted)
{
if (!bInterrupted)
{
// Re-enable movement, reset combo state, etc.
bIsAttacking = false;
}
} See Also
Tags
Version History
Introduced in: 4.0
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?