top of page

Implementing your behavior tree

Now that we’ve made a behavior tree, let’s get it to work in the game.

​Setting up the scene

  1. Create a capsule game object in the scene

  2. Add the Behavior Tree Executor component

  3. Assign the behavior tree you've made to the Behavior field

implementation-create-and-assign-agent.gif

Override blackboard

Observe that a new section just appeared in the inspector: the blackboard.

 

This blackboard holds variable overrides. When looking for a variable, the behavior will first search this blackboard for overrides, and then the original blackboard.

This allows us to create unique settings for this agent, or to provide scene references like a game object target.

example-override-blackboard.png

Creating a target

Let’s create a target cube to put into this variable override.

  1. Create a 3D cube and call it “Target Cube”

  2. Select the agent

  3. Drag the Target Cube into the value slot of the Target variable.

implementation-assign-target.gif

Action!

We are now ready to see the behavior in action.
You should see a green line is drawn between the agent and the target. 

implementation-in-action.gif

Blocking the view

But... not much else is happening.

 

Let’s place a wall between the agent and the target.

implementation-in-action-with-wall.gif

Now the line turns red and is interrupted when the wall obstructs the view!

And we’re done! You have just created your own behavior tree.

bottom of page