RealDocs

UAnimInstance::ConditionalFlushCompletedMontages

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

Description

Destroys any montage instances that have reached zero weight and are queued for removal. Called automatically each evaluation frame, but can be invoked manually to force immediate cleanup.

Caveats & Gotchas

  • Calling this while iterating the MontageInstances array will invalidate the iterator. Never call it inside loops that walk the active montage list.
  • In normal gameplay code you should never need to call this manually — the engine calls it at the correct point in the evaluation pipeline. Calling it prematurely can fire end delegates at an unexpected time.

Signature

ENGINE_API void ConditionalFlushCompletedMontages();

Return Type

void

Example

Force montage cleanup before querying active instance count C++
// Rarely needed — only if you must have an accurate count outside of tick
AnimInstance->ConditionalFlushCompletedMontages();
int32 ActiveCount = 0;
for (const FAnimMontageInstance* Inst : AnimInstance->MontageInstances)
{
    if (Inst && Inst->IsActive()) ++ActiveCount;
}
UE_LOG(LogTemp, Log, TEXT("Active montages after flush: %d"), ActiveCount);

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.