UAnimInstance::IsInitialized
#include "Animation/AnimInstance.h"
Access: public
Specifiers: ENGINE_API
Description
Returns whether this anim instance has completed its initialization and is ready for use. Initialization occurs after the skeletal mesh component sets the anim instance class, compiles the animation blueprint proxy, and calls InitializeAnimation.
Caveats & Gotchas
- • An uninitialized anim instance can exist briefly between construction and the first InitializeAnimation call. Calling animation functions (Montage_Play, GetCurveValue, etc.) on an uninitialized instance results in undefined behavior or no-ops — always check this flag when accessing an anim instance from external code that might run early in the lifecycle.
- • Re-initialization can occur when the animation blueprint class is changed at runtime via SetAnimInstanceClass. During the transition, IsInitialized temporarily returns false even on an instance that was previously fully initialized.
Signature
ENGINE_API bool IsInitialized() const; Return Type
bool Example
Guard early access to the anim instance C++
void AMyCharacter::BeginPlay()
{
Super::BeginPlay();
if (UAnimInstance* AnimInstance = GetMesh()->GetAnimInstance())
{
if (AnimInstance->IsInitialized())
{
AnimInstance->Montage_Play(IntroMontage);
}
else
{
// Defer until animation is ready
GetMesh()->OnAnimInitialized.AddLambda([this]() {
GetMesh()->GetAnimInstance()->Montage_Play(IntroMontage);
});
}
}
} See Also
Version History
Introduced in: 4.0
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?