RealDocs

UAnimInstance::ClearMontageInstanceReferences

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

Description

Removes all internal tracking references to a montage instance — slot weight maps, active instance lists, and slot node bookkeeping — in preparation for its destruction.

Caveats & Gotchas

  • This is an engine-internal cleanup function called automatically by OnMontageInstanceStopped. Calling it manually on a still-playing instance will corrupt the AnimInstance's internal state and cause incorrect blending or crashes.
  • After this call the instance is no longer referenced by the AnimInstance but may not yet be freed from memory — the TSharedPtr/TArray holding it controls the actual deallocation.

Signature

ENGINE_API void ClearMontageInstanceReferences(FAnimMontageInstance& InMontageInstance);

Parameters

Name Type Description Default
InMontageInstance FAnimMontageInstance& The montage instance whose references should be removed from internal tracking structures.

Return Type

void

Example

Understanding the call context (engine-internal use) C++
// You will typically NOT call this directly.
// The engine calls it from the montage stop path:
//   FAnimMontageInstance::Terminate()
//     -> UAnimInstance::OnMontageInstanceStopped()
//       -> UAnimInstance::ClearMontageInstanceReferences()
//
// If you are subclassing UAnimInstance and overriding OnMontageInstanceStopped,
// always call Super to ensure this cleanup runs:
void UMyAnimInstance::OnMontageInstanceStopped(FAnimMontageInstance& Stopped)
{
    Super::OnMontageInstanceStopped(Stopped); // calls ClearMontageInstanceReferences internally
}

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.