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?
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
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
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 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…