Download

How to add a minimum distance to a simple move to Attack function?

I currently struggle to have my AI stop at a certain distance from the player and begin attacking. The way i got this is it starts attacking at a specified distance, but then it still keeps moving until overlapping the player character.

There is a simple move to function which does this. However, would it be possible to restrict this simple move to function to a certain radius?

look at my ai project you will find exactly what you need

I use some Blueprints from exactly this project, however i spawn the Enemy AI randomly and there are no default TargetPoints set, thus no patrolling atm. So i guess it depends on those default values, how would i set them on Event Begin Play, for instance? Because of the Chase Function the AI runs up to the Player until overlap, it only plays the attack animation while doing that. I study this project since two days and i learned a lot, thanks for sharing it.

you can simply set all the variable(target points array,speeds,distances…) at beginplay event , but if you want having custom values for each instance , after the spawn node because they are all public.

for target points you can use GetAllActorsOfClass node , and you can fill you array as you want without having to set it manually

Well i got the Waypoints/patrolling working with this
deftps.jpg

But the AI is still running up to the Player, i guess the problem is different then, hmmm

look at the detection area

In your example the AI is running to the player too (up close until overlap), thus there is no minimum distance.

The chase function, the simple move to needs to get a minimum distance or radius, or the GetDistanceToPlayer function. During Attack Mode the AI is still chasing until overlap…

Notice also that i converted your project to 4.7.2

Idk, maybe this is relevant too Component Overlap Event not firing Component Overlap Event not firing - UE4 AnswerHub

Have you considered using “AI Moveto” - function in blueprints? THere you can specify the distance where it stops moving (set it to attack range) ?

Thanks for this useful input, i went and cut a lot of stuff and ended up with this

5f46f06657aab3ce47bccb79ad57cb7a0191380e.jpeg

This works now with the minimum radius! Now i just need to get the patrolling right…

if you run into a problem with enemies running up and smacking a player have a glance at how I go about it in my game and see if it gives you an idea or so… https://forums.unrealengine.com/showthread.php?47183-Alice-in-Tokyo-Wonderland-Blueprint-Only-Action-Hack-n-Slash&p=188019&viewfull=1#post188019

Thanks President, though the radius with AI move to just seems to be right, not sure why you use Simple move to too or PawnSensing. But thanks anyway your project offers various great bits, like those random attacks.

Pawn sensing is for another enemy that roams around the Maze level…doesn’t mean much to 90% of the enemies and yeah I stopped using Simple move to an switched it to AL move to since this video was recorded…I’m looking forward to seeing your progress in your game…thanks…