Paper2D - How can one create an enemy that does melee attack?

Hello everyone,

I hope there will be someone helping me to sort this out. I didn’t see any topics about this anywhere. Maybe I’m not a good researcher about ue but I try. I did find tutorials showing how to create an enemy who is shooting bullets.
Well, what I would like to make is, an actor/enemy following the player when the player gets close to them. So then, enemy will attac with its sword for example.

Is there any tutorials about making such thing? If not, can anyone explain it here? So maybe it can be added to UE docs or I can make a video tutorial for it so new comers will find it and that would be good for them as well.

Thanks a lot!
I really do appreciate any kind of help about this. :slight_smile:

There are multiple ways to do meele, from simple to complex. There’s been plenty of games that use raycasts just like bullets to attack but make it so they have a very short range.

Here’s a super-simple example that should help you get started. Basically this would evaluate if an enemy is within meele range, if so do a raycast(no aiming involved in this example) straight from self to enemy location in order to make sure it’s not blocked by a wall or another actor, if so do immediate damage with a do once to prevent it from being called every frame if it was placed in Tick such as this example, and after a delay of 1 second reset the DoOnce to attack again.

It’s a simple example, but if you added in an animation it would get the job done. If you wanted it to be so that one actor has to face another to hit him, you’d just have the linetrace end be self-actor-location + (self->getactorrotation->getforwardvector*200float or whatever distance range your attack should have)