What is best practice for handling animation stance changes via AI controlled behavior?

This is a followup to my question in the AI support stream, twitch username PandaGod_

I have a few situations regarding standard solider like AI that may be in cover, crouching or in prone. Those states/stances may be sub trees/leafs within a behavior tree. Currently they are separate animation state machines that power locomotion and blend into upper body behavior in the anim blueprint.

My current use case that I don’t handle as cleanly as I like is as follows:
AI is prone on the ground and firing. AI prone subtree is interrupted by a higher priority behavior. The higher priority behavior than executes an action that may or may not play a unique animation. That animation might not be compatible with the prone stance and in theory shouldn’t need to handle all potential stances.

Ideally when the subtree is interrupted I can play the prone to idle transition and switch stances before the behavior starts executing.
I currently execute this by a cease relevance blueprint service that switches a boolean on the anim blueprint that causes the transition anim to play in the state machine. I have to add in a hacky delay to wait for the transition to finish so the new higher priority task doesn’t force a bad blend with its unique animation.

I might be doing this poorly or maybe I need to handle the current animation stance in the higher priority task. In the ideal world the behavior tree doesn’t care about animation what so ever and under the hood the transitions and blends all happen perfectly, but I don’t see how to decouple that logic with the engine as it stands.

The ideal way, from the AI logic point of view, is to have BT request animation stance change by setting some “Desired Pose” value on AIs AnimationInstance (the Animation Blueprint), and have that blueprint use that value in animation state machine’s transition conditions. The most convenient way of binding stances with BT logic flow would be to implement a BT service that implements OnBecomeRelevant and OnCeaseRelevant and sets/resets the “Desired Pose” to configurable values.

This can easily be done in blueprints alone.

Cheers,

–mieszko

Yeah I’ve ended up doing that. Some random transitions from a state machine animation to a unique full body montage don’t blend great, but I guess that’s more of an animation problem than anything AI related.
Thanks for the response.

I also wouldn’t recommend doing this purely in BP for networked games unless the service updates a replicated value on the character which in turn updates the anim instance since the anim instance is not replicated.

True that.