Advanced enemy AI tips?

Hey, guys. So, I’ve been watching a lot of UE4 tutorials on how to make an enemy AI on YouTube. I think I’ve got the basics covered. I’ve gotten my enemy to chase the player and roam when the player is not in sight. Does anybody have any advice on how I can make my AI more realistic? I’m using this AI to make a horror game similar to Outlast and Slender. Any help would be greatly appreciated. Here’s the blueprint for my enemy AI:


I want my enemy AI to do three things:

  • Chase
  • Attack
  • Flee

I’m a newcomer to Unreal from Unity, so, my visual scripting game isn’t the best. Could someone please help me in showing me how I can make my enemy do these three things? If so, it would be much obliged. Please and thanks in advance!

You will need to learn how to use the AI specific blueprints.
This series is from an Epic Games twitch live stream where he teaches how to utilize these classes.

A lot of the other videos on Youtube for AI, from what I’ve found, are older and displaying how to code a very simple AI without even touching the Behavior Tree or Blackboards.

Good Luck on your journey of madness @_@

The unreal tutorials are also heavily outdated, they are from 4.7 and are already very advanced and somehow are hard to listen to.

I found this dude extremely good at explaining the why and how to think. His ai tut might not fit your project, but looking over his channel videos you’ll see he takes this way farther than these first 5 for his guard.
he then changes the guard from using pawn sensing components to ai perception components and then does work on MOB AI…
He speaks slowly and is exact and works for other games as you’ll see on his channel. Doing these tutorials as is…is a great way to get the understanding about how things work.

AI is DIFFICULT. don’t get too frustrated and if you do…just take a break or work on other aspects. Often times you’ll notice that taking an overnight break does wonders and when you open the editor again…the problem source might just dawn on you.

one thing to be careful of too is thinking too complicated just because AI programming is complicated as it is…some things can be solved with a simple solution. I just solved a year long problem that has been eating my soul with the correct placement of a single node.

I wish you luck.

Thank you ^^ :stuck_out_tongue:

I found out that behavior trees are great for cases when you have swarms of relatively simple ai bots.
Maybe i did not learn them fully, but there are problems (spots) where i feel like fighting behavior tree more than telling it what to do.
It is very easy to make simple bot that runs or attacs depending on simple conditions, but i alwas hit wall when making them more complicated.
Stuff like i can implement this or this, never both functions.

For more complicated AI go for Enviromental Query System + blueprint, with pawn sensing.
This combo is great. EQS is very nice system for finding potential places to go, shoot etc.

Yeah I just got 1 tree to finally work with a bot who patrols on lowest priority, will go to an area where he heard a sound and chill for a bit there, then continue patrolling…if he sees an enemy he will immediately stop patrolling and start shooting…and lastly, proving to be the most difficult of all, was for me to shoot them while moving to a random spot on patrol…and immediately abort that route, turn and start firing away…so in any case to the left of patrolling i finally figured out how to make them abort.
The key was a service setting bools on the BB to 0 on the selector above the 3 sequences…a node called “clear value” hooked to a “get blackboard”. it suddenly worked then.

I am very proud of that…getting one to work like this over the last 16 hours was fun while really attempting to not get frustrated and smash my monitor with a chainsaw that has a mounted rocket launcher on it. hehe

Still havent started with ai_perception or EQS because that stuff is just…pawnsensing, the oldschool…is hard enough.

I agree that behavior trees are usually the way to go, however most tutorials only cover the “patrol and chase player” kind of a bot. If you’re not using a standard character pawn and/or you want something more complicated, you just have to trial and error :frowning:

For instance, my game is a car game, so it’s definitely not a character pawn. AI MoveTo is out of the question, as is a navmesh, since a navmesh would let the player wander away from the road. I got the AI to follow a route but trying to integrate a consistent collision avoidance - (hit location + (hit normal * 50) sometimes giving VERY weird values - and/or detecting when it overshot a target is a pain.

Can recommend the work from

Use Behavior trees.
After trail and errors with it, I learned that putting a decorator on task nodes is good for breaking out of the node.
It takes a lot of trial and error since there isn’t a clear current documentation on it.
Also, EQS is very useful.

Outside of UE, you should learn some game AI paradigms like G.O.A.P.

I found this guy’s videos to be insanely helpful. There was something I wanted to do with my AI, like have him attack only within a certain radius, and I didn’t think it could ever be done, but because of this guy I made it happen. He now works for Naughty Dog and unfortunately stopped uploading a year ago. :frowning:

I tried using pawn sensing like you, but it doesn’t give you the flexibility of AIPerception and behavior trees. I would use pawn sensing for something like a turret, or zombies, and that’s it.