RealDocs

UAnimInstance::GetMontageInstanceForID

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

Description

Returns the FAnimMontageInstance with the given unique ID, enabling reliable lookup of a specific instance even when the same montage asset is playing multiple times concurrently.

Caveats & Gotchas

  • Returns nullptr if the instance has already been destroyed (e.g., the montage finished before this call). IDs are not reused within a session but the instance lifetime is short — store IDs only as transient handles.
  • The instance ID is assigned internally by the engine and is available on FAnimMontageInstance::GetInstanceID(). There is no Montage_Play overload that directly returns the ID; you must retrieve it immediately after play via GetActiveMontageInstance or GetActiveInstanceForMontage.

Signature

ENGINE_API FAnimMontageInstance* GetMontageInstanceForID(int32 MontageInstanceID);

Parameters

Name Type Description Default
MontageInstanceID int32 The unique numeric ID assigned to a montage instance when it was started.

Return Type

FAnimMontageInstance*

Example

Track and cancel a specific montage instance by ID C++
// At play time, capture the instance ID
AnimInstance->Montage_Play(AbilityMontage);
if (FAnimMontageInstance* Instance = AnimInstance->GetActiveMontageInstance())
{
    ActiveMontageID = Instance->GetInstanceID();
}

// Later, stop only that specific instance
if (FAnimMontageInstance* Instance = AnimInstance->GetMontageInstanceForID(ActiveMontageID))
{
    Instance->Stop(FAlphaBlend(0.2f));
}

Version History

Introduced in: 4.14

Version Status Notes
5.6 stable

Feedback

Was this helpful?

Suggest an edit

Select a field above to begin editing.