RealDocs

UAnimInstance::GetStateMachineInstanceFromName

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

Description

Retrieves a state machine node instance by its name as defined in the Animation Blueprint. Provides read access to state machine runtime data such as current state, transition info, and state weights.

Caveats & Gotchas

  • Returns nullptr if no state machine with the given name exists in this anim instance's graph. The name must exactly match the state machine's name property in the Animation Blueprint editor.
  • Returns a const pointer — you cannot modify state machine state through this accessor. To trigger transitions programmatically, use transition events or set variables that drive transition rules instead.

Signature

const FAnimNode_StateMachine* GetStateMachineInstanceFromName(FName MachineName) const

Parameters

Name Type Description Default
MachineName FName The name of the state machine as defined in the Animation Blueprint graph.

Return Type

const FAnimNode_StateMachine*

Example

Query current state of a named state machine C++
void UMyAnimInstance::LogCurrentState()
{
    if (const FAnimNode_StateMachine* SM = GetStateMachineInstanceFromName(FName("Locomotion")))
    {
        int32 CurrentStateIndex = SM->GetCurrentState();
        UE_LOG(LogAnimation, Log, TEXT("Current locomotion state index: %d"), CurrentStateIndex);
    }
}

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.