-
Notifications
You must be signed in to change notification settings - Fork 8
Tutorial 2
This section isn't really a tutorial.
If you open up the behavior tree editor and click on the behavior tree drop-down box (beneath the file menu), you will find a small selection of behavior trees that I built while developing the BadBehavior framework.
WanderTree
-
This is very similar to the lookAboutTree that we built in Tutorial1, but instead of using ScriptEval nodes to run TorqueScript commands, this tree uses a ScriptedBehavior node to call the wanderTask behavior which is written in a normal TorqueScipt file.
-
If you open up scripts/server/BadBehavior/BadBot.cs, you will find the wanderTask behavior definition which is used by the move somewhere node.
-
To use it:
Bob.setbehavior(WanderTree)
-
To tether the bot to a specific location:
Bob.tetherPoint = "0 0 0"
will keep bob wandering around the origin.
PatrolTree
- This behavior tree makes the bot follow a path.
- To use, first specify the path that Bob will follow. For example, there is a path named PatrolPath in the behaviorTestbed mission. We can make Bob follow it using:
Bob.path = PatrolPath;
Bob.setBehavior(PatrolTree);
A powerful feature of the BadBehavior system is the ability to assemble large, complex behavior trees from smaller trees.
The BotTree is an example of this. Each of the SubTree nodes is a link to another behavior tree, including the PatrolTree and WanderTree that we looked at previously.
BotTree defines the behavior for a simple deathmatch brawler, and illustrates the use of three extremely powerful nodes - Parallel, ActiveSelector and SubTree.
To see it in action:
Bob.setbehavior(BotTree);
The behavior trees can be used for more than AI. The system is designed to allow for behavior trees to be run on any SimObject. As an example of this, let's try out the botMatchTree. This runs a behavior tree which manages a simple gametype.
Before we start, pull down the console and enter:
setGodMode(1);
This will prevent the bots from targetting you.
Then we can start a bot match with 20 bots by entering into the console:
botMatch(20);
20 bots will be spawned and begin to fight each other.
See scripts/server/BadBehavior/botMatch.cs
for details.