UAnimInstance::GetRelevantAnimTimeFraction
#include "Animation/AnimInstance.h"
Access: public
Specifiers: UFUNCTION
Description
Returns the current normalized playback position (0.0–1.0) of the most relevant animation in the specified state, where 0.0 is the start and 1.0 is the end. Provides a play-rate-independent measure of how far through the animation the sequence player is.
Caveats & Gotchas
- • For looping animations the fraction wraps back to 0.0 at each loop boundary. A transition rule checking for fraction > 0.9 will fire once every loop iteration — this is usually intentional but can cause unintended transitions if not guarded with additional state.
- • This is the time fraction, not the remaining fraction. To check how much is left, use GetRelevantAnimTimeRemainingFraction, or subtract this value from 1.0.
Signature
UFUNCTION(BlueprintPure, Category="Animation", meta=(BlueprintInternalUseOnly = "true"))
float GetRelevantAnimTimeFraction(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
Blend in an additive pose during the second half of an animation C++
float Fraction = GetRelevantAnimTimeFraction(MachineIdx, ActionStateIdx);
// Fade in the additive during the back half of the animation
AdditiveBlendAlpha = FMath::Clamp((Fraction - 0.5f) * 2.f, 0.f, 1.f); Tags
Version History
Introduced in: 4.8
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?