Behavior Trees to create AI?

Hello, I am trying to create an AI in our first person game. One that goes to certain areas and performs certain actions. What is the best way to create such an AI? My goal is to make the AI be able to “walk” to certain locations. Such as walk up to the player and do something. The mesh for the AI we are trying to create has a walk animation. Also, if Behavior Trees is the way to do this would someone please explain how they work? I would greatly appreciate any information!

  • Sohile

Hi Sohile,

There does not seem to be any information in this post that needs to be private. Other users are interested in this information, so I am changing this question to public for now.

Thank you,

Alexander

Hey,

Behavior Trees are still WIP, but the editor is accessible as Epic Lab feature (you can enable these in editor preferences). This means you can use them but be ready to tell bye-bye to your assets when next iteration comes on line since we’ll not be supporting any backward compatibility. If you enable BT editor you’ll be able to open Shooter Game’s (one of sample projects) BT assets.

In general link posted by Mothership.Entertainment (this one) is a great place to start if you don’t know anything about behavior trees.

For now (if you don’t want to use experimental features) all you can do is what Dave.Voyles said in his answer in this thread. But if you want to read book chapter he linked skip all the navmesh info since it has nothing in common with UE4’s navmesh implementation (except for the name and general purpose it serves).

Cheers,

–mieszko

You can access the editor but it lacks several tools, you CANT recreate the shootergame behaviour, ive already tried

I’m using a Utility System for the AI in my game, it’s an Alternative to Behavior Trees. This book describes a system for them that is easy to implement in any language. It is very simple though.

Basically:

Your AI has a list of Acitons, the Action with the highest value is performed. That’s it in a nutshell.

Each Action has a list of Axis, these are what calculate the value for that particular Action. These Axis generally are what look at game state or an input as their Y value for input into a function that will then calculate the X.

If everything is kept normalized 0 to 1 you can multiply all the axis together to add up and give the Action the value. You can add weighting to the Actions to push a particular one, such as if it’s a scripted Action you could have 5 as a multiplier to a particular Action, scripted Actions would then always be selected over non scripted ones as long as it’s value was not 0.

http://www.amazon.com/Behavioral-Mathematics-Game-Dave-Mark/dp/1584506849/ref=sr_1_1?ie=UTF8&qid=1384877089&sr=8-1&keywords=behavioral+mathematics+for+game+ai

I actually wrote a chapter in my book, UnrealScript Gameplay Programming Cookbook, about this.

We’re all here for Rocket, an although this code is from UnrealScript, it should carry over nicely to UE4’s C++. Regardless, it will give you a better understanding of how to program AI using trees, and how pathfinding works.

Here’s the chapter.

Essentially you are creating a series of switch statements, based on the current conditions of the AI pawn. For example, what it can see, how much health it has, and the weapons / ammo it is currently armed with. Line of sight also plays a key role.

Let me know if I can be of any more help.

There’s also a really good explanation of behavior trees up on AIGameDev: http://aigamedev.com/insider/presentations/behavior-trees/

It seems there is Behaviour Tree editor coming.You can create Behaviour Tree in content browser if you look at Miscellaneous section.
Although I haven’t been able to do much inside it.

The ShooterGame bot behavior tree has 2 green nodes: [Search for enemy] and [Shoot enemy]. How can we add these nodes using the Epic Labs behavior tree editor?

EDIT: Looks like these are linked to blueprints, which call a function on the AIController every tick. Still not sure how to add them to the behavior tree though.

As Mieszko says, documentation is coming soon! In the meantime, I answered some questions about how to setup the trees on page two of a forum post on the topic: Behavior Tree Tutorial

I’ll post a link to official docs as soon as they’re available.