Game Development Reference
In-Depth Information
The behavior tree demo
Now that we know about the different nodes we can use, we'll create a demo that
shows how to use the action and decision nodes. The demo will show how to have
a character perform multiple tasks. We will have an entity, an enemy spaceship,
patrolling an area, but only for a given amount of time; then, the ship will return to its
home base. The steps for this example might seem overly complicated and we could
do a similar AI ourselves without behavior trees with a simple script by hardcoding
the different states. However, remember that behavior trees are easily extendible and
scalable. With this demo, instead of two behaviors, we could take time to create a
more complex character, going up to about 30 behaviors easily, but extending a script
to do that would be pretty complicated and hard to maintain.
The start of this is similar to the pathfinding and patrol RAIN demos, except we will
use a spaceship model instead of a walking character. You'll need to create a simple
scene with a ship model (the examples have a ship.blend model you can use) and
an object for the home base. The initial setup should look something like this:
Then, add RAIN to the scene, create a waypoint route to patrol the block, create a
navigation mesh, and add an AI to the ship. Remember that the ship model should not
interfere with the navigation mesh creation; you can set it to a different layer, such as
Ignore Raycast , and then in RAIN's navigation mesh menu, deselect this layer from
the Included Layers dropdown:
Search WWH ::




Custom Search