UAnimInstance::GetRelevantAssetPlayerInterfaceFromState
#include "Animation/AnimInstance.h"
Access: public
Specifiers: ENGINE_APIconst
Description
Returns the most relevant asset player node from the specified state in a state machine. This is the primary asset player driving the animation in that state, used by AnimGetters to query time, length, and remaining time.
Caveats & Gotchas
- • Returns null if the state has no asset player or if the machine/state index is out of range. The 'most relevant' player is determined by blend weight — in a blend of multiple sequences, the one with the highest weight wins.
- • The returned pointer is only valid during the current animation update. Do not cache it across frames, as the relevancy map is rebuilt each tick.
Signature
ENGINE_API const FAnimNode_AssetPlayerRelevancyBase* GetRelevantAssetPlayerInterfaceFromState(int32 MachineIndex, int32 StateIndex) const; Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| MachineIndex | int32 | Index of the state machine, obtained from GetStateMachineIndex. | — |
| StateIndex | int32 | Index of the state within the machine. | — |
Return Type
const FAnimNode_AssetPlayerRelevancyBase* Example
Query the dominant animation in a state C++
int32 MachineIdx = AnimInstance->GetStateMachineIndex(FName("Locomotion"));
const FAnimNode_AssetPlayerRelevancyBase* Player =
AnimInstance->GetRelevantAssetPlayerInterfaceFromState(MachineIdx, 0);
if (Player)
{
float Remaining = Player->GetCurrentAssetLength() - Player->GetCurrentAssetTime();
UE_LOG(LogAnimation, Log, TEXT("Time remaining: %.2f"), Remaining);
} Tags
Version History
Introduced in: 4.11
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?