UAnimInstance::GetRelevantAnimTimeRemaining
#include "Animation/AnimInstance.h"
Access: public
Specifiers: UFUNCTION
Description
Returns the time remaining in seconds before the most relevant animation in the specified state reaches its end. Used in transition rules to trigger a transition just before an animation finishes, enabling seamless looping or chaining.
Caveats & Gotchas
- • 'Most relevant' is determined by the highest-weighted sequence player in the state. In blend states with multiple sequences, this may not be the animation you expect — inspect the state's blend weights if the value seems incorrect.
- • For looping animations this always returns a positive value and will never reach zero naturally. Transition rules that fire 'when time remaining < X' will trigger once per loop cycle, which may be intentional for synchronized transitions.
Signature
UFUNCTION(BlueprintPure, Category="Animation", meta=(BlueprintInternalUseOnly = "true"))
float GetRelevantAnimTimeRemaining(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
Trigger a transition 0.2 seconds before an animation ends C++
// Inside a transition rule that fires when the attack animation is nearly done
bool UMyAnimInstance::ShouldTransitionFromAttack() const
{
return GetRelevantAnimTimeRemaining(MachineIdx, AttackStateIdx) <= 0.2f;
} See Also
Tags
Version History
Introduced in: 4.8
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?