Download

Create AI Enemy with Melee attack + animation

Hi everyone, i have an AI enemy that moves over the volume nav and have a sensor pawn for detect an actor, i can hit and destroy it, but i dont know how i can recive attacks from him and sinc that with an anim, i tried with an EventOverlap and EventHit(both with capsule of the blueprint) but isnt what i want.
I would to know if any of you have a solution :).
I’m new with UDK and I do not know many resources.

There are several ways to do it, Behavior trees or based on detection - then the AI follows the player when in radius (which could be a sphere collision added to the AI blueprint, or based on line traces, when the AI traces a vector radius). For the animation Unreal uses the animation blueprint, where you have different states to blend animations, depending on the situation (is the AI falling, is the AI speed 0 (idle), or is the AI attacking/blocking/dodging etc). There are many video tutorials on YouTube, as well as ready projects with examples.

Now i’m using line trace for detect the actor and work fine. On youtube i just found videos about AI Enemys and volumen nav for move when detect a player but nothing for receive attacks from an AI. Thank for help me! :slight_smile:

For attacks you need to add min max damage values on node AnyDamage, the damage can be calculated on overlap event. Overlap events work when you have your weapon, and then attach a collision capsule to the weapon(For Overlaps to register you need 2 actors, with enabled “Generate Hit Events”), and then add an overlap event to the collision capsule (right panel - the green buttons), and just enable Generate Hit Events for your target, i.e. your player’s Mesh or Capsule.

At your AI Blueprint you create a custom event, with your attack animation to enable collision. You have to add on your actual AI attack animation a anim notify event wich calls the AI Blueprints custom collision to enable/disable collision on attack start and end.

The attack could be initiated inside your AI Controller (another separate file), you add a node to your AI’s blueprint, to begin attacking (a node to a custom attack function, inside your AI Blueprint).

Here is a detailed tutorial on Melee, which explains a lot of the basics https://www.youtube.com/user/immigrantinc/videos