UAnimInstance::GetStateMachineIndex
#include "Animation/AnimInstance.h"
Access: public
Specifiers: const
Description
Returns the index of a state machine by its name. The index can be used with GetStateMachineInstance to retrieve the runtime state machine node for querying current state, weights, and transition information.
Caveats & Gotchas
- • Returns INDEX_NONE if no state machine with the given name exists in this anim instance. Always validate the result before passing to GetStateMachineInstance.
- • State machine indices are stable for the lifetime of the compiled Animation Blueprint — they do not change at runtime. However, recompiling the Blueprint may reassign indices.
Signature
int32 GetStateMachineIndex(FName MachineName) const Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| MachineName | FName | The name of the state machine as defined in the Animation Blueprint. | — |
Return Type
int32 Example
Get state machine index for runtime queries C++
void UMyAnimInstance::NativeUpdateAnimation(float DeltaSeconds)
{
Super::NativeUpdateAnimation(DeltaSeconds);
int32 LocoIndex = GetStateMachineIndex(FName("Locomotion"));
if (LocoIndex != INDEX_NONE)
{
const FAnimNode_StateMachine* SM = GetStateMachineInstance(LocoIndex);
CurrentStateIndex = SM ? SM->GetCurrentState() : INDEX_NONE;
}
} See Also
Tags
Version History
Introduced in: 4.0
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?