Choose a task type
Tasks are the building blocks of a behavior tree. Choose the category that matches the job, then combine tasks so the graph communicates the agent’s decisions from top to bottom.
- Actions perform work, such as waiting, moving, sending an event, or changing a value.
- Conditionals answer a question with Success or Failure.
- Composites choose the order in which several children run.
- Decorators change how one child runs or reports its result.
The original Behavior Designer does not have Event nodes. Event-driven behavior uses the Send Event Action, Has Received Event Conditional, conditional aborts, and the component event API.
Add and inspect tasks
Right-click the graph or press Space to open the task list, choose a category, and select a task. Select a node to edit its fields, Name, Comment, and Instant setting in the Inspector. Use descriptive custom names when a built-in name does not explain the task’s role in this tree.
Right-click a task to copy, paste, duplicate, delete, enable, disable, replace, collapse, set a breakpoint, or locate its script. The exact commands depend on the selected task and editor state.
Understand the task lifecycle
Create project-specific logic by deriving from Action, Conditional, Composite, or Decorator and overriding only the lifecycle methods the task needs.
| Method | When to use it |
|---|---|
OnAwake |
Cache stable references once when the behavior is enabled. |
OnStart |
Reset per-run state immediately before the task becomes active. |
OnUpdate |
Perform the task’s main work and return Running, Success, or Failure. |
OnLateUpdate / OnFixedUpdate |
Run phase-specific work; OnUpdate still owns the returned status. |
OnEnd |
Release per-run state after Success, Failure, or interruption. |
OnPause(bool) |
Respond when the owning behavior pauses or resumes. |
OnBehaviorRestart / OnBehaviorComplete |
Respond to the owning tree restarting or completing. |
OnReset |
Supply editor defaults when the task is reset. |
OnDrawGizmos / OnDrawNodeText |
Add Scene-view or node-level authoring feedback. |
GetPriority() supports Priority Selector, and GetUtility() supports Utility Selector. Task helpers also expose the owner, GameObject, Transform, component lookup, coroutines, and Unity collision, trigger, controller, and Animator callbacks. Use OnEnd for Action or Conditional cleanup after a conditional abort. OnConditionalAbort(int childIndex) is a ParentTask traversal hook, not a general task-cleanup callback.
Return the correct status
- Return
TaskStatus.Runningwhile work must continue on another update. - Return
TaskStatus.Successwhen the intended result is complete. - Return
TaskStatus.Failurewhen current conditions prevent completion and a parent should stop or try another child.
A task that never returns Success or Failure keeps its branch active. A task that returns Success before asynchronous work completes lets the tree continue too early.
Understand Instant
When Instant is enabled, the tree may continue to the next task during the same Behavior Manager tick after this task finishes. When disabled, traversal waits for the next tick. Disable Instant when a one-tick boundary is intentional; do not use it as a substitute for returning Running while real work is incomplete.
Continue with Writing a New Conditional Task, Writing a New Action Task, or Parent Tasks. For complete trees built from several tasks, browse Common Behaviors.