UAnimInstance::GetRelevantAnimLength
#include "Animation/AnimInstance.h"
Access: public
Specifiers: UFUNCTION
Description
Returns the total length in seconds of the most relevant animation sequence in the specified state. Useful for computing expected transition timing and for matching animation duration to gameplay events.
Caveats & Gotchas
- • The returned length is the asset length, not the effective playback length if a play rate multiplier is applied. Multiply by the inverse of the play rate to get the real-time duration at the current speed.
- • Returns 0.0 if the state contains no active sequence players. Always guard against zero before dividing by this value.
Signature
UFUNCTION(BlueprintPure, Category="Animation", meta=(BlueprintInternalUseOnly = "true"))
float GetRelevantAnimLength(int32 MachineIndex, int32 StateIndex) const; Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| MachineIndex | int32 | Index of the state machine containing the state. | — |
| StateIndex | int32 | Index of the state to query. | — |
Return Type
float Example
Synchronize a cooldown timer to the attack animation length C++
float AttackLength = GetRelevantAnimLength(MachineIdx, AttackStateIdx);
GetWorld()->GetTimerManager().SetTimer(
AttackCooldownHandle,
this,
&UMyAnimInstance::OnAttackCooldownEnd,
AttackLength,
false
); Tags
Version History
Introduced in: 4.8
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?