Community Tutorial: The Easiest Way to Make a Simple Enemy AI in Unreal Engine 5

Hello guys, in this quick and simple tutorial we are going to make a simple enemy AI, which will follow the player, have its own vision area, and attack when it’s near the player in Unreal Engine 5.

Follow me on Twitter: https://twitter.com/GorkaGames
Subscribe to the channel: https://www.youtube.com/channel/UCv_n9oioNF6OpzR2dt6E4xg

unreal engine 5,ue5,enemy ai,tutorial,quixel,megascans,unreal engine tutorial,how to make enemy ai,ue5 enemy ai,ue5 how to make ai simple,unreal engine enemy ai,unreal engine 5 how to make enemy ai,unreal engine 5 simple enemy ai,unreal engine ai system enemy,unreal engine 5 enemy ai simple system, unreal engine 4 enemy ai,unreal engine 4,ue4,unreal engine 5 how to make simple enemy ai

https://dev.epicgames.com/community/learning/tutorials/188R/the-easiest-way-to-make-a-simple-enemy-ai-in-unreal-engine-5

1 Like

…why do you set the IsSeeingPlayer? to True before calling FollowPlayer and then within FollowPlayer, check if IsSeeingPlayer? is true or false? it’s ALWAYS going to be True at that point before FollowPlayer gets called, as FollowPlayer never gets called until after IsSeeingPlayer? is true. What’s even the point of that Bool or the Branch within FollowPlayer?

Also, at the CanAttack? part, you set the value to true, then check if it’s true (of course it is! it always will be at this point!), then set it to false claiming that’s to prevent it from attack spamming (that’s not true at all. by the time this point in the code is reached, setting it to false will not prevent the Branch from going True because you set it to True at the start before the Branch), and then you do the animation montage and do a delay (the truly ONLY thing preventing attack spamming, is the delay), and then once again set the CanAttack? to true again… That Branch is useless because the moment it gets to that branch the value will always be true, every time. So why is it even there?

Then you went back and set IsSeeingPlayer? to false after checking if it was already false… that does nothing. This part of that branch will never happen. What’s the point?

The PawnSensing already does half the work you attempted to do in this (when PawnSensing sees the player, it sees the player, you don’t need to set any bools to true to MAKE it see the player, you only need to have it Do Stuff from PawnSensing seeing the player), which is why it was shown to be working when you playtested it. The moment PawnSensing is no longer detecting the player, it no longer calls the code after it. You only need it to attempt to move towards the player when it sees the player, it won’t keep trying to follow the player when it no longer sees the player because it wouldn’t call the code to follow the player when it isn’t seeing the player.