RealDocs

UAnimInstance::GetStateMachineIndexAndDescription

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

Description

Looks up a state machine by name and returns both its baked description and its index in a single call. Combines the functionality of GetStateMachineIndex and GetMachineDescription for convenience when you need both values.

Caveats & Gotchas

  • OutMachineIndex is set to INDEX_NONE and the return value is nullptr if no state machine with the given name exists. Always check the return value before using the index.
  • The name lookup is performed against the compiled Animation Blueprint data. If the state machine was renamed in the editor without recompiling, the old name will still be used until the Blueprint is recompiled.

Signature

const FBakedAnimationStateMachine* GetStateMachineIndexAndDescription(FName InMachineName, int32& OutMachineIndex)

Parameters

Name Type Description Default
InMachineName FName The name of the state machine to look up.
OutMachineIndex int32& Output parameter that receives the machine index, or INDEX_NONE if not found.

Return Type

const FBakedAnimationStateMachine*

Example

Get state machine index and description together C++
void UMyAnimInstance::QueryLocomotionMachine()
{
    int32 MachineIndex;
    if (const FBakedAnimationStateMachine* Desc = GetStateMachineIndexAndDescription(FName("Locomotion"), MachineIndex))
    {
        UE_LOG(LogAnimation, Log, TEXT("Machine '%s' at index %d with %d states"),
            *Desc->MachineName.ToString(), MachineIndex, Desc->States.Num());
        
        // Use MachineIndex to get the runtime instance
        if (FAnimNode_StateMachine* Instance = GetStateMachineInstance(MachineIndex))
        {
            // Query runtime state
        }
    }
}

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.