What is Automatic Rule Based Transition
?
Automatic rule based transition
is used, in most cases, if you want an auto-transition from source state to target state when the source animation ends.
For example, consider a state transition from State Jump_Land
to Idle
:
An alternative way to implement state transition condition is to use Get Relevant Time Remaining
node like this:
But this is, to some extent, dirty and expensive. We cannot use Animation
variable with it, even worse, Fast Path
does not work with this way.
The proper method in this case is to check Automatic Rule Based on SequencePlayer in State
of this transition:
Transition would start when there is 0.2 second left in the source state animation. This is clean and elegant.
Problem With Back-Playing Sequence
For the official UE4 engine, Automatic Rule Based Transition
does not work with a back-playing sequence. Because transition only cares about the accumulated time of an animation asset.
1 | if (UAnimationAsset* AnimAsset = RelevantPlayer->GetAnimAsset()) |
As a result, for a back-playing animation sequence, it does not work as expected. Hence some modifications are needed:
1 | // FAnimNode_StateMachine::FindValidTransition |
We need to add a function for each FAnimNode_AssetPlayerBase
to get real play rate:
1 | // FAnimNode_AssetPlayerBase |
And override this function in FAnimNode_SequencePlayer
:
1 | float FAnimNode_SequencePlayer::GetEffectivePlayRate() |
And that’s it! Enjoy this feature!