Help Making Enemies Animate their attacks

Hey all,

I’m attempting to build the first enemy AIs in our game using blackboards and behavior trees. The problem I am running into is trying to get the enemies to animate during their attack step.

I have a player moving around and animating using an animation blueprint etc. I have an enemy using a behavior tree and moving towards the player and even firing “mind bullets” through an attack node but I can’t get the darn enemy to animate his attacks. I know how to set the blackboard keys in the behavior tree, I just don’t know how to pass that information over to any part of the enemy character, ai controller, or anim graph.

This is probably something real basic, but I’ve been trying for two days and have no clue. :frowning: Do I use Blueprint Interfaces? If so, what is the context?

Please help, my forehead is sore from banging it on my keyboard for two days!

I have a question up on AnswerHub that is unanswered as to the best way to call an animation from a BehaviorTree.

So, what I’m doing may not be the best way, but it’s working so far.

I use Blueprint Interfaces. From the BehaviorTree Task I call the function on the Anim Blueprint for the pawn I want to animate. The called function just sets a bool to true on the Anim Blueprint, such as StartAttack. In the Event Graph of the Anim Blueprint I sequence, first I set the locamotion variables, then I branch check the StartAttack bool. It that’s true I branch Again and check it the Montage is playing, only if it is not I call the montage.

In the behavior tree, I have a wait node to the right of the task that called the attack animation of the same length of the attack animation itself. I have a related unanswered question on AnswerHub to do with that. I think it’s non-maintainable to have wait nodes all over the place tied to animation lengths which may change. I think you are supposed to return in progress from the Task node that called the animation but I don’t know how to do that. My way is probably either a hack, or a workaround to a bug they haven’t discovered yet because not many people are working with Behavior Trees in a Blueprint only environment yet.

I then have a node call StopAttack. If the branch checking the bool StartAttack is false I check if the Montage is Playing, if it is I set Stop. I need to fix the last part. As I said, this probably isn’t the way, but it’s a start if you just want to start playing montages from the BT.

Awesome! That is the same logic I have been trying to do but it isn’t working. My problem is syntax I think. In the blueprint interface I have one function called EnemyIsAttacking that has no outputs or inputs. I have that interface attached to the BTtask blueprint and the anim blueprint.

How do I tell that function to run from the BTtask so that the animblueprint is the one running it?