– Edit: I think I made it look more complicated than it actually is. I can simplify my question as:
Provided that you can access an array of full-body anim sequences, how would you create an Animation BP that picks an anim sequence at random from the array, play it until it’s finished, and repeat?
Blending is a nice bonus, but I could do without.
(See below for some backgound)
In our project, our characters can play many attack animations. We have different classes of characters, and I want to keep a simple, generic base AnimBP, and be able to add animations easily when adding a new character class.
In practice, I would like to have one “Attack” anim state, deciding which animation to play before entering it, staying in the state until the anim is almost done playing, and blending back to the idle state.
Here is an example of what I don’t want to do:
What I tried instead is to add properties of type AnimSequence in the AnimBP, and feed them to the Play Anim node using the Sequence input pin. That way, instead of having to instanciate a Play node for each animation in the state and selectively blend between them, I can pick one at runtime and feed it to a single Play node.
I’m not sure if this is a recommended practice. It works most of the time, but I hit a few times an assert in AnimSequenceBase.cpp:
check( bPlayingBackwards ? (CurrentPosition <= PreviousPosition) : (CurrentPosition >= PreviousPosition));
I suspect that it happens when going out and back in the Attack state, while the previous attack animation is still playing, and I swap it with a new one.
So my questions:
- Is using the “Sequence” input pin of the Play anim node the way to play variables animations in an anim graph ?
- Is the anim graph evaluated in the game thread, and if not, how safe is it to change the input value at runtime ?
- Would you recommend a more low-level approach, like a custom animation player that, given an array of AnimSequences, decides which one is best to play ? I don’t exclude creating a custom animation node.
I have looked at Montage and branch points, but as far as I understand it requires specifying the sections manually, and in my case each character class has a variable number of animations.
Again, the key difficulty here is that I’m looking for a generic solution where I can add animations at a later point without touching the base AnimBP.