I made a state machine that, in one of its states, reads an AnimSequence variable from its pawn owner, and plugs that into a Play node, like this:
You’ll note that the node says “Play ThirdPersonWalk”. The only way to play an anim sequence from a variable that I found was to create a “Play <X>” node, then tick the “(As pin) Sequence” box. Is this the correct way to do this?
The problem with the above is that if I make a transition rule based on, say, time remaining for the animation that’s playing, it will always take the length of the original anim sequence used to create the Play node (ThirdPersonWalk in this case), not the length of the sequence that was passed in through the pin.
I made a minimal project to reproduce the problem based on the ThirdPerson template. Pressing the left or right mouse button changes the character’s anim instance class to a different anim BP. This BP first plays a dynamically assigned anim (ThirdPersonWalk if you pressed the left button, ThirdPersonJump_Loop if you pressed the right mouse button). When this anim is past its 90% mark, it will transition to a new state that plays ThirdPersonJump_End, and then switch back to the original anim instance class. However, because I plugged the anim sequence variable into a “Play ThirdPersonWalk” node, and the ThirdPersonJump_Loop anim is much shorter, the machine will never transition from the first state to the second if you pressed the right mouse button.
Someone mentioned that attempting to play a raw clip with out a wrapper of some kind the clip does not get reset when entering and exiting. Next time you trigger the state the animation will continue to play where it left off. Makes some sense as a clip is not very data driven friendly.
My opinion is its a better solution to first place all of your sequences into some kind of wrapper and clamp the input to the desired output and drive the sequence with data instead of a simple event trigger.
You could wrap the sequences as a single Montage or my favorite use a blend space which is nothing more that a 1 or 2 dimensional array.
Unfortunately due to the way animation blueprints are currently compiled the original node sequence will always be queried in a transition. We should be sorting this out soon and allowing runtime overrides and variable-driven players to be queried correctly. Sorry for the inconvenience.
A way to do it is to wrap your sequences into a blend space which can accept a variable.
This is a behind the scene video of me working with my coder.
Old video now that I have figured out how to do indexed blends in the animgraph I’m going to switch to matched sets,idle > start > walk > stop, and since it’s now 100% data driven the input can come from anything by just normalizing the input values.