Download

How do I interrupt an animation sequence and blend back to a pose?

I’ve got a giant monster which performs an animation sequence where he reaches his hand out to grab a smaller character. He then bites the characters head off and then flings the corpse aside.

I’m trying to wrangle animation blueprints, creature blueprints and behavior trees to get this to work just right and I’m running into some areas of confusion. I have an anim notify event which fires in the animation sequence at the moment the monster makes a grab. This anim event then calls a function within the character blueprint which polls a collider to see if there’s actually a creature there (it may have moved and dodged the attack!).

Here’s where I get in trouble: If the grab animation misses, I need to get the monster back into his ‘neutral’ position which is an idle pose and this means that I need to interrupt the currently playing animation at its current frame and somehow do a blend back to its first frame or just play the grab animation in reverse. I don’t know how to do this.

First I think it’s best to use a montage for this kind of animations, you can easily play, stop, reverse them if you want.
But if you really want to use animation sequence you can put the grab attack in a state of a state machine, then you can switch to idle state at any time using a boolean.

I figured out how to do this as cleanly as possible. It took a bit of engineering effort to get it right, but I think I’ve got it as minimalist as possible. Here is my architecture:

f9fb879327c3c9e27ddc60960a87d92c480cbafb.jpeg

Within the animation blueprint state machine, I have this for the anim sequence:
00d291ad4014ffa59081c789fd257131dc99234e.jpeg

The animation blueprint has a few anim notifies which call functions within the creature. There’s an anim notify called “Grab” which activates at a specific part of the animation sequence. The anim bp has an event which gets triggered during this grab notify. The event then calls a function within the creature blueprint to check if we actually grabbed something. This blueprint node will run and update the blackboard with an “aborted” value if we didn’t grab anything. The Anim Blend node (above) will check for any change to the action status, so if it moves to anything but “in progress”, it blends back to the “idle” position. The behavior tree task is also continuously polling the blackboard for the status of the action. If the action becomes aborted or complete, we call “finish execute” so that the behavior tree can move on to the next task.