User Tools

Site Tools


gettingstarted:creatingbehavior

Creating Behavior

In RAIN, behavior can range from simple to highly sophisticated. To build behavior in RAIN, you will be using the Behavior Tree Editor.

Be sure to also read Behavior Trees Overview.

Behavior Trees are the primary feature for doing Behavior in RAIN. Building behavior has been dramatically simplified, however, it still requires an understanding of logic and is still only a tool. Building complex behavior still requires an understanding of how Behavior Trees work. This section will introduce you to some of the basic concepts of Behavior Trees, and get you started making Behavior Trees of your own.

Intro to Behavior Trees

Behavior Trees are based on the concept that decision making for an AI can usually be broken down into a set of hierarchically organized tasks. Higher level tasks near the root of the hierarchy usually define a mechanism for choosing between or organizing the execution of lower level tasks. Tasks at the bottom or edge of the tree (usually “leaf nodes” in programming parlance) are typically specific actions that can be carried out by game logic. In RAIN, these tasks take the form of behavior tree nodes.

Creating Behavior

To Start:

  1. Open the Behavior Tree Editor by selecting from the menu RAIN » Behavior Tree Editor. You can also access a shortcut from the AI Mind.
  2. Create a new behavior tree by selecting it from the drop down. This will create a basic tree with a sequencer container in it.

From this point, you now need to make a decision on what behavior you want to build. Here are some tips on constructing your behavior tree logic:

  1. What end result do you want to accomplish with this AI?
  2. Break out each specific behavior into its own branch or separate behavior tree asset.
  3. Use constraint and expression nodes to help make decisions that will determine whether a branch or node is executed.
  4. Use sequence nodes when you need tasks to execute successfully one after the other until one fails.
  5. Use selector nodes when you need it to execute nodes until it returns a success on one.
  6. You can open the active behavior tree for your character and review it as it runs.
    1. Red = failed, orange = running/failed, yellow = running, green = success
    2. Drag the behavior tree nodes around while running for real time updates to better understand the execution process.
  7. Check out Behavior Trees for more information about the actual usage of behavior trees.

If you have followed this Getting Started series, you should now be able to:

  1. Create the AIRig that will be used to manage your AI motion, animation, mind (behavior), etc..
  2. Create a Navigation Mesh used to graph the playing area and provide the AI Navigator with information it can use to perform path searches and routing.
  3. Create a behavior tree where you can define self contained behaviors much like a HFSM without transitions.
  4. Create waypoint path sets that will be used by Navigator in conjunction with the Navigation Mesh to define a route to a vector position defined by each waypoint. Once the target position is defined, the Navigator can provide the AI Motion element with the target to move to.

These are all essential steps in creating functional AI. You should now be ready to investigate the specifics on how to accomplish the desired goals for movement and behavior. Continue from here by reviewing RAIN Elements and Components to learn more about managing your AI.

Next Steps

See Also

gettingstarted/creatingbehavior.txt · Last modified: 2022/08/13 18:13 (external edit)