AI melee combat?

Hello friends! I’m working on a third person game and I need AI melee combat. I’m currently following these tutorials and have made it to part 7, everything is working fine but now I need to implement melee combat instead of ranged shooter combat, and since I’m a complete noob, I don’t know how to proceed. I’ve managed to make it so that my line trace for the attack is much shorter, and so that my enemy only does damage when in line trace range. I’ve tried to make it so that the line trace doesn’t do damage, but instead casts to my AIs blueprint and fire an event to do damage, but that hasn’t worked. So, long story short, my basic questions are 1) how do I apply an attack event to do damage? 2) How do I apply my attack animation? 3) Can I get my AI to stand still and do the event/animation, and when that’s done, continue to follow the player?

Sorry if this is badly phrased, I’m literally just learning scripting all in all and have never written a line of code in my life, so all of the terms are still a little fuzzy to me.

Okay, so, I got the animation running, but just once. I think this is because I’m only setting my boolean that I use in the AIs anim bp to true, and never reset it after the event/damage has executed.

I tried doing this through my behaviour tree attack task by simply setting the boolean to false once the event fired, but then it didn’t play the animation at all. I tried putting in a sequence before casting to the AIs bp and firing the event, so that I first cast the event and then set the boolean to false, but had the same problem with the animation not firing at all. Lastly, I tried to set the boolean to false through the BTT again. I put the boolean right after the event (cast from AIs bp). But instead of using the ‘as Enemy AI’ output from the cast node, I tried making a variable reference to the AI. But the weird part is that when I tried to set that up in my behaviour tree (in the attack task, set the enemy to that blueprint) nothing happened, even though it looks like I should be able to specify it. Somebody knows what I’m doing wrong? I’ve included screenshots where you can see my variable inside the attack task event graph, and then in my behaviour tree where I’m supposed to be able to specify the blueprint (the dropdown shows the blueprint I want to target=, but when I click it, nothing happens (‘spider’ is still just set to ‘none’).

87318-attacktask.png

![alt text][3]

I figured it out! Instead of trying to uncheck the boolean in the BTT I unchecked it in the anim BP and now the animation runs just as it should.