← All namespaces

behavior_tree

AI & gameplay Experimental

Author Behavior Tree graphs and decompile to BTIR text.

What it's for

This namespace lets your assistant build and edit Unreal Behavior Tree assets from a chat request, instead of you dragging nodes around the Behavior Tree editor by hand. It can create a new tree, add composite and task nodes at chosen graph positions, wire parents to children, and hang decorators and services off the nodes that need them.

Use it when you are laying out AI logic: a patrol-then-chase sequence, a selector that falls back through several tactics, or a task node with a conditional decorator guarding it. Because every node lands at an explicit x/y, the resulting graph stays readable when you open it in the editor rather than piling up at the origin.

It also decompiles a tree (or its Blackboard) to BTIR, a compact text form of the graph. That is the fast way to give your assistant the current shape of a tree before it edits, and to review a change as a diff-friendly snapshot afterward.

This area is experimental and still improving. Method names, parameters, and the BTIR text format may change between releases, so pin behavior you depend on and re-check after upgrading.

Examples

Build a patrol-then-chase tree from scratch

The assistant creates the asset, drops a root Sequence with two child nodes, and connects them.

You: Make a BT_Guard behavior tree: a Sequence that first Waits, then MoveTo.

  call("behavior_tree.create", {name:"BT_Guard", savePath:"/Game/AI"})
    → {ok:true, assetPath:"/Game/AI/BT_Guard"}
  call("behavior_tree.add_node", {assetPath:"/Game/AI/BT_Guard", nodeType:"Sequence", x:0, y:0})
    → {ok:true, nodeId:"A1"}
  call("behavior_tree.add_node", {assetPath:"/Game/AI/BT_Guard", nodeType:"Wait", x:-160, y:200})
    → {ok:true, nodeId:"B2"}
  call("behavior_tree.add_node", {assetPath:"/Game/AI/BT_Guard", nodeType:"MoveTo", x:160, y:200})
    → {ok:true, nodeId:"C3"}
  call("behavior_tree.connect_nodes", {assetPath:"/Game/AI/BT_Guard", parentNodeId:"A1", childNodeId:"B2"})
    → {ok:true}
  call("behavior_tree.connect_nodes", {assetPath:"/Game/AI/BT_Guard", parentNodeId:"A1", childNodeId:"C3"})
    → {ok:true}

Done. BT_Guard has a Sequence running Wait then MoveTo.

Read an existing tree as text before editing

The assistant decompiles the tree to BTIR so it works from the real graph, not a guess.

You: Show me how BT_Enemy is structured.

  call("behavior_tree.decompile", {assetPath:"/Game/AI/BT_Enemy"})
    → {btir:"tree { Selector { Sequence { ... } Wait { ... } } }"}

Done. Read BT_Enemy: a top Selector over a chase Sequence and a Wait fallback.

Guard a node and tweak its properties

The assistant attaches a decorator to a task and sets fields on the node instance.

You: On the MoveTo node in BT_Guard, add a blackboard-based decorator and set the Wait to 2 seconds.

  call("behavior_tree.attach_decorator", {assetPath:"/Game/AI/BT_Guard", parentNodeId:"C3", decoratorClass:"Blackboard"})
    → {ok:true, nodeId:"D4"}
  call("behavior_tree.set_node_properties", {assetPath:"/Game/AI/BT_Guard", nodeId:"B2", properties:{WaitTime:2.0}})
    → {ok:true}

Done. MoveTo is now blackboard-gated and the Wait is set to 2 seconds.

← Back to all namespaces