Download

Some questions about how to build enemy AI

For the past couple of weeks I’ve been looking at tutorials and videos about Unreal Engine. One of the things I can’t really get a grasp of is AI. To be more specific, I want to create a RPG like project. I want to have an enemy AI that uses different abilities and attacks between melee and ranged. I understand the best way of approach would be to utilize the behavior tree for the AI to switch between states based on the relative position/status of the player to use different attacks/abilities. The thing I’ve noticed in a lot of these tutorial videos is that the enemy AI is very bland. What I specifically mean is that in these videos the AI will chase the player wait, do an attack, wait and repeat the process. It doesn’t seem very natural, and I do get that in these videos its designed to be simplistic with only one attack pattern.

My first question would be how would you approach setting up the behavior tree to dynamically and naturally use certain attacks/abilities, retreat etc.?

My second question is in regards to Animation. When creating animation for movement/locomotion and attacks/abilities do you also need to create blend spaces that the AI can also use to make movement and attacks seem more natural, how would you do so?

My last question would be in regards to the limitations of Blueprints. I understand that blueprints may have some limits as to what it can do compared to C++, but what are some examples of these of what blueprints can’t do. Maybe in relation to and RPG/gameplay perspective.

I am still very much a novice in regards to blueprints and I’m trying to learn more about C++ as well. I want to apologize if this question was answered before, I looked through the forums search but couldn’t really find an answer to any of these questions. Please let me know if you want me to clarify something!

Thanks!

Well in short, building dynamic, natural, and complex AI is not a small task but if you learn about behavior trees one step at a time you will soon be able to start putting things together. But to answer your questions:

  1. Take a look into custom behavior tree tasks and decorators. Through decorators you can define your own conditionals to tell the AI things to do next like execute certain tasks or run a child behavior tree. With custom tasks you can define what exactly you want the ai to do, just like a method in c++. Then it just comes down to what you want it to do. So in your case, you would want a decorator to check distance or state and then switch attacks with a new task. From there you can run a new behavior tree depending on whether its ranged or melee and again create some more decorators and tasks to determine which ability is used. When it comes down to it, behavior trees are a different way to organize code execution but its doing the same things.

  2. Yes, you do need to make blend spaces for your attacks. Animations function the same for ai as for your player character. Take a look into the free paragon character animations and blueprints. They will give you the best idea on how to go about setting up character animations.

  3. In terms of gameplay programming there’s really not much, but the benefit that c++ provides is a 10x speed increase for calculations done on tick or per frame. This allows you to program more complex behaviors or whatnot without losing as much performance as in blueprints. Also, c++ allows you to better control memory management and optimization. In my opinion for indie devs or smaller games, blueprints will suffice for almost all your needs but if you find yourself doing some complex math on tick that’s bogging things down, try to transfer that to c++. Also, with c++ you can make custom plugins and include external libraries and whatnot which can allow you more freedom in development.

One suggestion I have for you is to take a look at the Free RPG project offered on the unreal marketplace. Ill post the link below. It is a c++ project but does more or less what you are trying to do. Good luck!

Ok, Thanks Bagel. This should be a good place to start!

No problem. Let me know if you have any further questions.