AnimMontage doesn't play in custom behavior tree task

I have an attack task that has my AI move to the player’s location and plays an AnimMontage for its melee attack. All my code works, but the animation doesn’t play. I borrowed some of the code from the PlayAnimation task, which works too. I feel like it might be something I did, but I can’t figure out what causing the bug. I’m using the launcher version of 4.7.2. Here’s the source code of my class: http://pastebin.com/r28M0Upa

The crucial bit you’ve missed from BTTask_PlayAnimation is this:

// instantiating to be able to use Timers
bCreateNodeInstance = true;

This is required to have timers notify the right BT node - otherwise your node class instance is a “skeleton” that’s being used for all AI using particular BT.

One thing I’ve noticed while looking through your code: your node will never do a move and play the animation in sequence and it wouldn’t be easy to make it that way. I suggest you used the BT structure for this kind of sequencing - combined with decorator conditions it’s perfect for the task!

Cheers,

–mieszko

Thanks for the help! Unfortunately the animation still doesn’t play in my custom task, but I’m not using it anymor, as I realized after I posted this question that I shouldn’t have combined MoveTo and PlayAnimation into the same node. That was kinda silly of me. :stuck_out_tongue: I’m now using the built-in MoveTo and PlayAnimation tasks with a custom decorator that checks if my enemy is in melee range. Unfortunately, I’ve run into another problem. After my character finishes the animation (which works in the built-in task), it defaults back to the T-pose. I’m assuming that’s a bug with the task itself. And whether or not it’s the engine or just something I did, how might I fix it/workaround it?

maybe it because when you use the build in play Animation it make the actor to switch the animation mode to not use the animation blueprint. it’s a bug, and miezko already recognize it (if what i think of your problem is not wrong). maybe you can fix it yourself. just make a custom playAnimation.(with code that entirely same with the playAnimation task, but on the end of the animation, just call [your USkeletalMesh variable]->SetAnimationMode(EAnimationMode::AnimationBlueprint);

because in the playAnimation task you can see that it use the playAnimation funciton on USkeletalMesh Class, and in that funcition it would set the animation mode to EAnimationMode::AnimationSingleNode. which is would alter the animation settings.

or you can use the AnimationMontage to play. for me, i still use the last one (not upgraded to the 4.7 yet, coz still trying things in the new build).

jejeje. cheers

For reference, this has been fixed on the master branch.

–mieszko