How do i make ai attack player

i made him to follow player and have attack anims ready but how do i get him to attack player and do damage etc die

1 Like

The simple way would be to create a trigger volume within the enemy blueprint the size of their ‘reach’ and check to see if any of the overlapping actors are the player when an attack happens. If the player is overlapping, use the built in damage nodes (right click, type damage, you’ll see them). The player is going to need Health variables, which you will decrease when the player detects incoming damage. (Same damage nodes, you’ll see ‘received damage any,’ for example. This will fire any time the player is damaged by your enemy).

Overall, if what I’ve just said is a bit confusing, you’ll want to hunt down a tutorial that will walk you through a health system, and tell you more about the built in damage system. This search on YouTube should get you started. https://www.youtube.com/results?search_query=ue4+health+system

Yes thank you i did it :slight_smile:

I have added everything like what you said, is there a way to add another animation when I hit that triger?

What do you mean ‘another’ animation? If you aren’t yet, try using animation blueprints to run your animations. That way you’ll just turn on a ‘is attacking’ bool or something, and have him set up to play whatever you need.