RealDocs

UAnimInstance::Montage_SetSectionChangedDelegate

function Engine Since 4.0
#include "Animation/AnimInstance.h"
Access: public Specifiers: ENGINE_API

Description

Binds a delegate that fires each time the active montage transitions to a new section, enabling section-driven game logic such as combo windows or state changes keyed to montage sections.

Caveats & Gotchas

  • The delegate fires for every section transition, including programmatic ones triggered by Montage_JumpToSection or loop-backs defined in the montage asset itself. Implement a guard if you only want to react to specific sections.
  • Section names are case-sensitive. A delegate registered on a montage with section 'Attack_1' will not fire if the asset was later renamed to 'attack_1'.
  • This delegate is not replicated. On clients in a networked game you must drive section changes via RPC or rely on Simulated Proxy correction.

Signature

ENGINE_API void Montage_SetSectionChangedDelegate(FOnMontageSectionChanged& InOnMontageSectionChanged, UAnimMontage* Montage = nullptr);

Parameters

Name Type Description Default
InOnMontageSectionChanged FOnMontageSectionChanged& The delegate to invoke whenever the active montage moves into a new named section.
Montage UAnimMontage* Target montage instance. Nullptr targets the topmost active montage. nullptr

Return Type

void

Example

Open a damage window when a specific montage section begins C++
FOnMontageSectionChanged SectionDelegate;
SectionDelegate.BindUObject(this, &AMyCharacter::OnMontageSectionChanged);
AnimInstance->Montage_SetSectionChangedDelegate(SectionDelegate, AttackMontage);

void AMyCharacter::OnMontageSectionChanged(UAnimMontage* Montage, int32 PreviousSectionIndex, int32 CurrentSectionIndex)
{
    FName CurrentSection = Montage->GetSectionName(CurrentSectionIndex);
    if (CurrentSection == FName("HitWindow"))
    {
        SetDamageWindowActive(true);
    }
    else
    {
        SetDamageWindowActive(false);
    }
}

Version History

Introduced in: 4.0

Version Status Notes
5.6 stable

Feedback

Was this helpful?

Suggest an edit

Select a field above to begin editing.