# Playing an animation through a Behavior Tree/BTTask

**URL:** <https://forums.unrealengine.com/t/playing-an-animation-through-a-behavior-tree-bttask/300451>\
**Category:** AI\
**Tags:** Behavior-Tree, bttask, unreal-engine, Blueprint, question\
**Created:** [December 3, 2014, 11:58am UTC](https://forums.unrealengine.com/t/playing-an-animation-through-a-behavior-tree-bttask/300451 "2014-12-03T11:58:44Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![tauren\_1](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@tauren\_1](https://forums.unrealengine.com/u/tauren_1)\
**Post date:** [December 3, 2014, 11:58am UTC](https://forums.unrealengine.com/t/playing-an-animation-through-a-behavior-tree-bttask/300451/1 "2014-12-03T11:58:44Z")

</div>

Hi,  
I’m trying to create a basic monster AI which would start chasing the player when in line of sight and attack once it reaches the player.  
I have followed the Behavior Tree Quick Start Guide and got the chasing working nicely. I have a custom character (one of the Mixamo pack) following me when in line of sight and it all works well.  
Now I am attempting a play an animation on this character after he reaches the player (A Swing animation that the mixamo character has), but it simply doesnt play the animation and I’m unable to figure out how to get it to work.

In the **RapidMoveTo task** ( As seen in **Step 10** [https://docs.unrealengine.com/latest/INT/Engine/AI/BehaviorTrees/QuickStart/10/index.html](https://docs.unrealengine.com/latest/INT/Engine/AI/BehaviorTrees/QuickStart/10/index.html)) , I added a reference to the AI Character (named Imp Character) and I called a play animation on it after it reaches the player. (image attached). But this animation simply doesnt play, I even tried creating an Anim Montage and playing it, but that doesnt work either.

 ![22833-playanim.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/6/d/e/6deba8426d7f42f300c8afd0bbe1afa4b6a72ed6.jpeg)

[https://docs.unrealengine.com/latest/images/Engine/AI/BehaviorTrees/QuickStart/12/fullTree.jpg](https://docs.unrealengine.com/latest/images/Engine/AI/BehaviorTrees/QuickStart/12/fullTree.jpg)

I would ideally create an “Attack” task and have it run through the BT, but I’m just trying to test it before I extend it as its own BTTask.

I am able to call an animation on the character through the character’s Event Graph, but I’d like to be able to have this work through BTs.

I apologize if this is a very basic thing, but after several hours of searching the wiki, I’m yet to get a simple “Play animation” to work through a Behavior Tree/BTTask. Any help would be greatly appreciated, thanks!

---

<div class="post-metadata">

**Author:** ![MieszkoZ](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@MieszkoZ](https://forums.unrealengine.com/u/MieszkoZ)\
**Post date:** [December 4, 2014, 11:43pm UTC](https://forums.unrealengine.com/t/playing-an-animation-through-a-behavior-tree-bttask/300451/2 "2014-12-04T23:43:03Z")

</div>

Have you tried debugging your blueprint task? How/where do you set your `Imp Character` in the blueprint?

–mieszko

---

<div class="post-metadata">

**Author:** ![tauren\_1](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@tauren\_1](https://forums.unrealengine.com/u/tauren_1)\
**Post date:** [December 5, 2014, 10:25am UTC](https://forums.unrealengine.com/t/playing-an-animation-through-a-behavior-tree-bttask/300451/3 "2014-12-05T10:25:39Z")

</div>

@Mieszko : Thanks for taking out your time! 🙂 Yes,I have checked the debugger in the blueprint task ( **RapidMoveTo** ) on the ImpAIController, it does trigger the animation,but doesnt really play it ingame.  
Here is a screen showing the Imp Character setup as a variable in the blueprint task :

 ![23035-impvar.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/c/b/d/cbd75f0ee643ca70ec9f39f47b73eac084a49da3.jpeg)

Also, as I mentioned earlier, I have no problem calling the animation directly from the Imp Character blueprint (seen below)

 ![23036-chargraph.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/6/a/0/6a0a55496f234be03aeb516a0202b9fae12f14e2.jpeg)

---

<div class="post-metadata">

**Author:** ![MieszkoZ](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@MieszkoZ](https://forums.unrealengine.com/u/MieszkoZ)\
**Post date:** [December 5, 2014, 4:02pm UTC](https://forums.unrealengine.com/t/playing-an-animation-through-a-behavior-tree-bttask/300451/4 "2014-12-05T16:02:24Z")

</div>

When debugging blueprints you can put breakpoints on nodes and mouse over variables to read their current value. I bet that if you put a breakpoint on the `PlayAnimation` node the value of `ImpCharacter` would be ‘None’. You need to set it, at runtime, to your `AIController`'s Pawn (with possible casting here and there).

---

<div class="post-metadata">

**Author:** ![tauren\_1](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@tauren\_1](https://forums.unrealengine.com/u/tauren_1)\
**Post date:** [December 6, 2014, 10:25am UTC](https://forums.unrealengine.com/t/playing-an-animation-through-a-behavior-tree-bttask/300451/5 "2014-12-06T10:25:38Z")

</div>

@Mieszko : That was it, works perfectly now! thank you very much 🙂  
My anim graph after the fix :

 ![23118-castedtoimpchar.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/3/1/8/31835c2154e249e6bab579d0cdb139b87e67426d.jpeg)

Now I can continue exploring the possibility of making the Attack as its own BTTask!

---

<div class="post-metadata">

**Author:** ![GMW](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@GMW](https://forums.unrealengine.com/u/GMW)\
**Post date:** [May 1, 2016, 8:10pm UTC](https://forums.unrealengine.com/t/playing-an-animation-through-a-behavior-tree-bttask/300451/6 "2016-05-01T20:10:04Z")

</div>

Hey, what is your AI con reference that you have connected to the target of the controlled pawn, I am trying to do something similar to yourself?
