Behavior Tree API Reference#
Purpose: Complete Python API for the Behavior Tree extension. For the visual authoring workflow and runtime debugging, see the User Guide.
Overview#
The behavior tree system has two layers:
Factory (
bt.get_factory()) — the standalone core. Creates trees, descriptors, node libraries, and blackboards. No USD or timeline dependency. You build and tick trees yourself. Use this for unit tests, headless simulation, or any context where USD is not involved.USD Runtime (
bt.get_bt_runtime()) — the USD integration layer. MapsBehaviorTreeAPIprims to tree instances,BehaviorTreeBlackboardprims to blackboards, andBehaviorTreeNodeLibraryprims to node libraries (for stage-scoped, one-off node libraries). During timeline play, the runtime creates these objects from their USD attributes and ticks all trees each frame. Available only when a stage is open.
Both are accessed through a single import:
import omni.behavior.tree.core as bt
Most users interact with the runtime through the tree editor UI. The factory API is needed for programmatic tree building and custom node implementations. The runtime API is useful when you need to look up the live tree, blackboard, or node library that corresponds to a specific prim.
Tree Execution#
USD-Managed Trees#
The primary way to run behavior trees is through the UI and USD:
In the tree editor, open a behavior tree JSON file and add it to compatible prims.
Press Play — the runtime creates tree instances and ticks them each frame with the timeline.
From Python, use Kit commands to set up tree prims:
import omni.kit.commands
from pxr import Sdf
# Apply BehaviorTreeAPI to a prim with a descriptor file
omni.kit.commands.execute(
"ApplyBehaviorTreeAPICommand",
prim_path=Sdf.Path("/World/MyRobot"),
tree_file_path=Sdf.AssetPath("path/to/tree.json"),
)
# Create a blackboard prim
omni.kit.commands.execute("CreateBlackboardCommand")
During Play, access live trees through the runtime:
import omni.behavior.tree.core as bt
runtime = bt.get_bt_runtime()
tree = runtime.get_tree("/World/MyRobot")
if tree:
bb = tree.get_blackboard()
bb["target"] = "/World/Goal"
The runtime also manages stage-scoped node libraries (BehaviorTreeNodeLibrary prims) and can reload them at runtime.
Available commands:
Command |
Description |
|---|---|
|
Applies |
|
Removes |
|
Creates a |
Manual Tree Execution#
For advanced use cases — unit tests, headless simulation, or trees not tied to USD — create and tick trees directly through the factory:
import omni.behavior.tree.core as bt
factory = bt.get_factory()
# Build a tree programmatically
lib = factory.get_node_library("omni.behavior.tree.core").get()
seq = lib.get_node_type_handle("Sequence")
wait = lib.get_node_type_handle("Wait")
desc = factory.create_descriptor()
desc.push(seq, "root")
desc.add(wait, "step1")
desc.add(wait, "step2")
desc.pop()
tree = factory.create_tree(desc)
while tree.get_status() != bt.NodeStatus.SUCCESS:
tree.tick(delta_time=1.0 / 60.0)
Trees can also be created from JSON:
json_str = open("tree.json").read()
desc = factory.create_descriptor_from_string(json_str)
tree = factory.create_tree(desc)
Building a Patrol Tree#
This example builds the following tree programmatically, combining core composites with behavior simulation nodes:
The agent picks a random point on the NavMesh, walks there, pauses, and repeats forever.
Note
The omni.anim.behavior.tree extension must be enabled for its node library to be registered.
The get_node_library() call and all type handles obtained from it will fail if the extension
is not loaded.
import omni.behavior.tree.core as bt
factory = bt.get_factory()
# --- 1. Acquire node libraries and type handles ---
core = factory.get_node_library("omni.behavior.tree.core").get()
anim = factory.get_node_library("omni.anim.behavior.tree").get()
seq_type = core.get_node_type_handle("Sequence")
wait_type = core.get_node_type_handle("Wait")
move_to_type = anim.get_node_type_handle("MoveTo")
repeat_type = core.get_modifier_type_handle("Repeat")
rand_pt_type = anim.get_modifier_type_handle("RandomNavMeshPoint")
# --- 2. Build the tree topology ---
# push() opens a scope for children, add() creates a leaf, pop() closes.
desc = factory.create_descriptor()
root = desc.push(seq_type, "patrol") # Sequence
go = desc.add(move_to_type, "go") # MoveTo
wait = desc.add(wait_type, "pause") # Wait
desc.pop() # close Sequence
# --- 3. Set port values on nodes ---
# override_node_instance_port(node, port_name, value_type, value)
desc.override_node_instance_port(
wait, "duration", bt.NodePortValueType.VALUE, 2.0
)
# --- 4. Attach modifiers ---
# attach_modifier(owner, modifier_type, name, abort_mode)
rpt = desc.attach_modifier(root, repeat_type, "loop")
# count=0 means repeat forever
desc.override_modifier_port(
rpt, "count", bt.NodePortValueType.VALUE, 0
)
rand_pt = desc.attach_modifier(go, rand_pt_type, "pick_dest")
# --- 5. Wire modifier output → node input ---
# RandomNavMeshPoint produces "point"; feed it into MoveTo's "target".
desc.override_node_instance_port_modifier(
go, "target", "pick_dest", "point"
)
# --- 6. Save and apply to a prim ---
# Character animation nodes run through the USD runtime, so serialize
# the descriptor to a file and attach it to the agent prim.
import omni.kit.commands
from pxr import Sdf
json_str = factory.serialize_descriptor(desc)
desc_path = "/path/to/patrol_tree.json"
with open(desc_path, "w") as f:
f.write(json_str)
omni.kit.commands.execute(
"ApplyBehaviorTreeAPICommand",
prim_path=Sdf.Path("/World/Character/SkelRoot"),
tree_file_path=Sdf.AssetPath(desc_path),
)
# --- 7. Play the timeline ---
# The runtime ticks all trees automatically each frame.
import omni.timeline
timeline = omni.timeline.get_timeline_interface()
timeline.play()
Creating Node Libraries#
Node libraries declare the node types available to tree descriptors. Libraries are owned by Omniverse extensions that manage their lifecycle.
C++ Extension#
For best performance, implement nodes as a C++ Carbonite plugin. Define nodes with
BT_NODE_DESC (see C++ API) and register them via BehaviorNodeLibraryBuilder.
A thin Python extension layer calls into the plugin to manage the lifecycle.
C++ plugin:
// nodes/GoToAction.inl
struct GoToAction : public IBehaviorActionNode
{
BT_NODE_DESC(
type = "GoTo",
doc = "Move agent toward target position",
constraints = BT_CONSTRAINTS("BehaviorAgentBaseAPI"),
ports = BT_PORTS(
valuePort("target", PortValue({ eFloat3, eSdfPath }, Variant{})),
valuePort("speed", 1.0f)))
NodeStatus onTick(IBehaviorActionNodeContext& ctx) override { /* ... */ }
};
// Extension.cpp
static UniqueNodeLibraryPtr g_library;
void registerNodeLibrary()
{
g_library = BehaviorNodeLibraryBuilder("my_extension.nodes")
.registerNode<GoToAction>()
.validate()
.build();
}
void unregisterNodeLibrary()
{
g_library.reset();
}
Python extension — acquires the plugin interface and calls register/unregister:
# extension.py
import omni.ext
import my_extension.bindings as _bindings
class MyNodesExtension(omni.ext.IExt):
def on_startup(self, ext_id):
self._iface = _bindings.acquire_interface()
self._iface.register_node_library()
def on_shutdown(self):
self._iface.unregister_node_library()
_bindings.release_interface(self._iface)
self._iface = None
Python Extension#
For rapid prototyping or ad-hoc nodes that don’t need native performance, implement nodes in Python. The extension creates the library on startup, registers decorated node classes, and releases the library on shutdown.
# extension.py
import omni.ext
import omni.behavior.tree.core as bt
from .my_nodes import GoTo, Patrol
class MyNodesExtension(omni.ext.IExt):
def on_startup(self, ext_id):
factory = bt.get_factory()
self._lib = factory.create_node_library("my_extension.nodes")
bt.register_node(self._lib, GoTo)
bt.register_node(self._lib, Patrol)
def on_shutdown(self):
self._lib = None # releases the library
Node classes are defined in separate modules using the @bt.node decorator.
Alternatively, the extension can load a script file with bind_node_library_with_script:
import pathlib
script = (pathlib.Path(__file__).parent / "my_nodes.py").read_text()
factory.bind_node_library_with_script(self._lib, script)
API Reference#
High-Level Helpers#
Function |
Description |
|---|---|
|
Returns the singleton |
|
Decorator that declares and registers a node or modifier type on a class (subclass of |
|
Creates an input port descriptor with a literal default value |
|
Creates an input port descriptor that references a blackboard key |
|
Creates an output port descriptor (for modifier output wiring) |
|
Registers a |
|
Serializes a Python object to a JSON string via the factory |
|
Deserializes a JSON string to a Python object via the factory |
|
Converts a Python object to its variant display string (empty string for |
IBehaviorTreeFactory#
Singleton factory for creating all behavior tree objects. Acquired via bt.get_factory().
Method |
Description |
|---|---|
|
Creates an empty descriptor for programmatic building with |
|
Deserializes a descriptor from JSON |
|
Creates an empty blackboard |
|
Deserializes a blackboard from JSON |
|
Creates a runtime tree instance |
|
Creates and registers an unversioned node library |
|
Creates and registers a versioned node library (version is a semver string, ext id string, or |
|
Creates and registers a node library from JSON |
|
Associates a node library with a Python script string; updates declarations and implementations |
|
Returns a |
|
Returns all registered libraries as weak references |
|
Serializes a descriptor to JSON string |
|
Serializes a blackboard to JSON string |
|
Serializes a node library to JSON string |
|
Serializes descriptor overrides to JSON string |
|
Deserializes descriptor overrides from JSON |
|
Serializes a variant value to string |
|
Deserializes a variant value from string |
Note
Node libraries are automatically unregistered when the Python object is garbage collected. There is no explicit unregister_node_library method in Python.
IBehaviorTree#
Runtime tree instance. Created via factory.create_tree().
Method |
Description |
|---|---|
|
Executes one tick; returns |
|
Resets the tree to idle state |
|
Returns current root node status |
|
Returns the last error message |
|
Returns the tree’s blackboard |
|
Returns the tree’s descriptor |
|
Returns a writable |
|
Returns a list of matching |
|
Returns a subtree |
|
Returns a subtree |
|
Returns an |
IBehaviorTreeDescriptor#
Defines tree structure. Created via factory.create_descriptor() for programmatic building, or factory.create_descriptor_from_string() from JSON. See Manual Tree Execution for a complete example.
Builder API#
The descriptor supports a push/pop scope model: push opens a scope (adds children), pop closes it. add creates a leaf without opening a scope.
Method |
Description |
|---|---|
|
Create a node and open its scope for adding children; returns |
|
Create a node with auto-generated name and open its scope |
|
Re-enter scope for an already-created node |
|
Create a leaf node and add to current scope; returns |
|
Create a leaf node with auto-generated name and add to current scope |
|
Close the current scope |
Topology Mutation#
Method |
Description |
|---|---|
|
Returns the root |
|
Returns list of child handles |
|
Returns the parent handle |
|
Detach a child from its parent |
|
Returns handle by node path |
Node Instance Queries#
Method |
Description |
|---|---|
|
Returns the type name of a node instance |
|
Returns the instance name |
|
Returns the |
|
Returns the resolved |
|
Returns names of ports with instance-level overrides |
Port Overrides#
Method |
Description |
|---|---|
|
Override a port’s value for a specific node instance |
|
Override a node port to reference a modifier’s output port |
|
Revert a port to its type-level default |
Modifiers#
Method |
Description |
|---|---|
|
Attach a modifier to a node; returns |
|
Detach a modifier from its owner |
|
Returns list of modifier handles for a node |
|
Returns handle by modifier path |
|
Returns the owner node handle |
|
Returns the type name |
|
Returns the instance name |
|
Returns the |
|
Returns the resolved |
|
Returns names of ports with overrides |
|
Override a modifier’s port value |
|
Revert a modifier port to type-level default |
Validation & Libraries#
Method |
Description |
|---|---|
|
Validates the descriptor; returns |
|
Returns referenced node libraries as weak references |
|
Checks if all referenced node libraries are still alive |
|
Checks if referenced libraries match their snapshot versions from creation |
IBehaviorNodeLibrary#
Collection of node type declarations and implementations. Create a library with factory.create_node_library(name), then register @bt.node-decorated classes with bt.register_node(lib, NodeClass). To load from a script, use factory.bind_node_library_with_script(lib, script_content).
Type Queries#
Method |
Description |
|---|---|
|
Returns all declared node type handles |
|
Returns all declared modifier type handles |
|
Returns the type name for a node or modifier handle |
|
Returns |
|
Returns the |
|
Returns |
|
Returns |
|
Returns the library name |
|
Checks if a specific type has an implementation |
|
Checks if the entire library has implementations for all types |
|
Returns |
|
Returns |
|
Copies declarations/implementations from another library |
Metadata#
Method |
Description |
|---|---|
|
Returns the library documentation string |
|
Sets the library documentation string |
|
Returns documentation for a node or modifier type |
|
Returns search keywords for a node type |
|
Returns documentation for a specific port |
|
Returns the display name for a port |
|
Sets a custom display name for a port |
|
Returns the enum choices for a port (for dropdown UI) |
Constraints#
Method |
Description |
|---|---|
|
Returns constraint strings (USD schema/API names) for a node or modifier type |
|
Returns constraint strings for the entire library |
Versioning & Migration#
Method |
Description |
|---|---|
|
Returns the version string of this library |
|
Registers a migration function; |
UI Customization#
Python-only methods for custom icons and port widgets (not persisted in JSON).
Method |
Description |
|---|---|
|
Sets a custom icon for a node or modifier type (supports carb tokens) |
|
Returns the custom icon path, or |
|
Sets a custom widget drawer for a port on a node or modifier type |
|
Returns the custom widget drawer, or |
IBehaviorBlackboard#
Typed key-value store shared across tree nodes. Supports Python dict-like syntax.
Operation |
Description |
|---|---|
|
Sets a value ( |
|
Returns the value ( |
|
Returns |
|
Removes a key ( |
|
Returns number of entries ( |
|
Returns a deep copy ( |
|
Removes all entries |
|
Returns all key names |
|
Returns the event name for a |
Node Callback Classes#
Base classes for implementing custom node behavior in Python. Subclass one of these and decorate with @bt.node().
Class |
Description |
|---|---|
|
Base class for leaf nodes that perform work |
|
Base class for branch nodes that control child execution |
|
Base class for modifiers (conditions, decorators) that wrap a target node |
All three classes support these callbacks:
Callback |
Description |
|---|---|
|
Called once when the node instance is created |
|
Called each tick; must return |
|
Called during normal execution when the node is reset ( |
|
Called exactly once when the tree is destroyed. The sole teardown callback — use it for resource cleanup and undoing side effects. |
Modifier additionally supports:
Callback |
Description |
|---|---|
|
Called to evaluate the condition; returns |
Node Execution Contexts#
Context objects passed to node callbacks during execution.
_INodeExecutionContext (base)#
All contexts share these methods:
Method |
Description |
|---|---|
|
Returns this node’s path in the tree |
|
Returns this node’s name |
|
Returns this node’s |
|
Returns current node status |
|
Returns status from previous tick |
|
Returns why the node was last reset |
|
Returns the last error message |
|
Returns the tick delta time |
|
Returns the tree’s blackboard |
|
Returns the tree instance |
|
Returns the event name for a |
IBehaviorActionNodeContext#
Passed to ActionNode.on_tick(). Inherits all base context methods, plus:
Method |
Description |
|---|---|
|
Returns input port value |
IBehaviorCompositeNodeContext#
Passed to CompositeNode.on_tick(). Inherits all base context methods, plus:
Method |
Description |
|---|---|
|
Returns input port value |
|
Returns number of children |
|
Returns child context (read-only) |
|
Ticks a child with default abort behavior; returns |
|
Ticks a child with specified |
|
Resets a child |
|
Returns why a child was last reset |
IBehaviorModifierContext#
Passed to Modifier.on_tick() and Modifier.on_check_condition(). Inherits all base context methods, plus:
Method |
Description |
|---|---|
|
Returns input port value |
|
Sets an output port value (for modifier-to-node port wiring) |
|
Ticks the owned node; returns |
|
Resets the owned node |
|
Returns the owned node’s context (read-only) |
|
Returns why the target was last reset |
Runtime Node Views#
IBehaviorTreeNode#
Writable view of a node at runtime, returned by tree.get_node(). Inherits all _INodeExecutionContext methods, plus:
Method |
Description |
|---|---|
|
Returns input port value |
|
Overrides an input port value at runtime |
IBehaviorTreeModifier#
View of a modifier at runtime, returned by tree.get_modifier():
Method |
Description |
|---|---|
|
Returns input port value |
|
Overrides an input port value at runtime |
|
Returns the owning |
|
Returns the tree’s blackboard |
|
Returns the tree instance |
|
Returns the modifier instance name |
|
Returns the full modifier path |
|
Returns current execution status |
|
Returns previous execution status |
Helper Functions#
Function |
Description |
|---|---|
|
Returns |
|
Returns |
Enums#
NodeStatus#
Value |
Description |
|---|---|
|
Node completed successfully |
|
Node failed |
|
Node still executing |
|
Node not yet ticked |
|
Node encountered an error |
NodeRole#
Value |
Description |
|---|---|
|
Leaf node that performs work |
|
Branch node controlling child execution |
NodeResetReason#
Value |
Description |
|---|---|
|
Tree or node was explicitly reset |
|
Node was aborted by parent or modifier |
ChildAbortBehavior#
Controls how child abort signals propagate:
Value |
Description |
|---|---|
|
Propagate abort to children |
|
Ignore abort signal |
ObserverAbortMode#
Controls when a modifier’s condition triggers an abort:
Value |
Description |
|---|---|
|
No abort behavior |
|
Abort this node when condition changes |
|
Abort lower-priority siblings |
|
Abort both self and lower-priority siblings |
NodePortValueType#
Value |
Description |
|---|---|
|
Port holds a literal value |
|
Port references a blackboard key |
|
Port references a modifier’s output port |
NodeLibraryVisibility#
Value |
Description |
|---|---|
|
Library is visible in the node catalog |
|
Library is hidden from the node catalog |
TreeNodeEvent#
Value |
Description |
|---|---|
|
Fired when a node’s status changes |
BlackboardEvent#
Value |
Description |
|---|---|
|
A new key was added to the blackboard |
|
An existing key’s value was modified |
|
A key was removed from the blackboard |
CloneNodeLibraryFlags#
Flags for copy_from():
Value |
Description |
|---|---|
|
Copy declarations only |
|
Also copy node implementations |
|
Also copy metadata (doc, keywords, etc.) |
Type Handles#
Type |
Description |
|---|---|
|
Handle to a declared node type within a library |
|
Handle to a declared modifier type within a library |
|
Handle to a node instance within a descriptor |
|
Handle to a modifier instance within a descriptor |
NodePortDescriptor#
Describes a port on a node or modifier type:
Field |
Description |
|---|---|
|
Port name (string) |
|
|
|
Default value (Python object) |
|
List of accepted variant type name strings |
|
List of enum choice strings (for dropdown UI) |
|
|
|
|
|
Name of the referenced output port (for |
BehaviorTreeDescriptorOverride#
Represents a port value override for a specific node instance:
Field |
Description |
|---|---|
|
Node instance identifier |
|
Port name |
|
|
|
Override value (Python object) |
|
Referenced output port name (for |
Port Helpers#
Port descriptors are created with bt.value_port(), bt.blackboard_ref(), and bt.output_port(),
then passed to @bt.node(..., ports=[...]).
bt.value_port(name, value=None, accepted_types=[], enum=[])#
Creates an input port with a literal default value.
Expression |
accepted_types |
default |
optional? |
|---|---|---|---|
|
|
|
no |
|
|
|
no |
|
|
|
yes |
|
|
|
no |
|
|
|
yes |
|
|
|
no |
Rules:
When
valueis notNoneandaccepted_typesis empty, the type is inferred from the value.When
valueisNone, the port is optional —get_input()returnsNoneuntil explicitly overridden.When
enumis provided,accepted_typesis forced to["string"]and the default is the first enum value (if not specified).
bt.blackboard_ref(name, key=None)#
Creates a port that references a blackboard key. If key is None, it defaults to the port name.
bt.output_port(name, value=None, accepted_types=[])#
Creates an output port. Output ports are set by modifiers via ctx.set_output(name, value) and can be wired
to other nodes’ input ports using NodePortValueType.MODIFIER.
Examples:
@bt.node(type="MyAction", ports=[
bt.value_port("speed", 1.0), # required float
bt.value_port("label"), # optional, any type
bt.value_port("mode", enum=["fast", "slow"]), # string dropdown
bt.blackboard_ref("target", key="enemy_pos"), # blackboard ref
])
class MyAction(bt.ActionNode):
def on_tick(self, ctx):
speed = ctx.get_input("speed") # always has a value (1.0 default)
label = ctx.get_input("label") # None if not overridden
return bt.NodeStatus.SUCCESS
Event System#
The behavior tree system fires events via carb.eventdispatcher. Event name and key constants are available as static properties on these classes:
Class |
Constants |
|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
Built-in Node Types#
See Built-in Node Library for the complete list of composite nodes, action nodes, and modifier types with their ports.
Variant Type Registry#
Python-side type registry for UI metadata on variant types:
Function |
Description |
|---|---|
|
Registers a |
|
Unregisters a variant type |
|
Returns |
|
Returns all registered canonical type names |
VariantTypeName provides constants for built-in types: NULL, INT64, DOUBLE, BOOL, STRING, FLOAT2, FLOAT3, FLOAT4, SDF_PATH, VARIANT_ARRAY.
USD API#
Schema Helpers#
Function |
Description |
|---|---|
|
Sets the tree descriptor file path on a prim with |
|
Returns the descriptor file path as |
|
Sets serialized blackboard data on a |
|
Returns serialized blackboard data string from a blackboard prim |
IBehaviorTreeUsdRuntime#
Acquired via bt.get_bt_runtime(). Available during Play. See Tree Execution for usage.
Method |
Description |
|---|---|
|
Returns the |
|
Returns the |
|
Returns the USD prim path string for a tree |
|
Returns prim paths of all tracked |
|
Returns prim paths of all tracked |
|
Re-reads USD attributes for a tree prim |
|
Returns a |
|
Returns all stage-scoped node libraries |
|
Reloads a node library by re-reading its script file |
|
Collects all constraint strings from node libraries used in a descriptor |
|
Validates whether a prim satisfies all constraints; returns |
|
Returns |
USD Schema Attributes#
BehaviorTreeAPI (applied schema):
Attribute |
Type |
Description |
|---|---|---|
|
asset |
Path to tree descriptor JSON file |
|
rel |
Relationship to blackboard prim |
|
bool |
Enable/disable tree execution (default: |
|
bool |
Auto-restart on completion (default: |
|
string |
JSON serialized descriptor overrides |
BehaviorTreeNodeLibrary prim type:
Attribute |
Type |
Description |
|---|---|---|
|
asset |
Path to Python node library script |
BehaviorTreeBlackboard prim type:
Attribute |
Type |
Description |
|---|---|---|
|
string |
JSON serialized blackboard data |
C++ API#
Headers are in include/omni/behavior/tree/. Include BehaviorTreeNodeUtils.h for the node
definition macros and BehaviorNodeLibraryUtils.h for the library builder.
BT_NODE_DESC#
Declares node metadata (type name, ports, documentation) as a static method on a node class.
Used by BehaviorNodeLibraryBuilder to auto-register nodes.
Uses named-parameter syntax — all parameters except type are optional and reorderable:
#include <omni/behavior/tree/BehaviorTreeNodeUtils.h>
struct MyAction : public IBehaviorActionNode
{
BT_NODE_DESC(
type = "MyAction",
doc = "Move agent toward a target position",
keywords = BT_KEYWORDS("movement", "navigation"),
constraints = BT_CONSTRAINTS("BehaviorAgentBaseAPI"),
ports = BT_PORTS(
valuePort("target", PortValue({ eFloat3, eSdfPath }, Variant{}))
.displayName("Target")
.doc("Target position or prim path"),
valuePort("speed", 1.0f)
.displayName("Speed")
.doc("Movement speed in m/s"),
valuePort("mode")
.strEnum("walk", "run")
.displayName("Mode"),
blackboardRef("status_key", "agent_status"),
outputPort("distance", PortValue(kFloatingPointTypes, 0.0f))
.displayName("Distance")))
NodeStatus onTick(IBehaviorActionNodeContext& ctx) override { /* ... */ }
};
Parameters:
Parameter |
Description |
|---|---|
|
(required) The node type name as it appears in the editor and JSON. |
|
Documentation string shown in the node catalog. |
|
Port declarations (see below). Wrap in |
|
Search keywords for the node catalog. |
|
USD schema/API names the target prim must satisfy. |
|
Enable coroutine mode: |
|
Internal debug name for logging. |
Port Helpers (C++)#
Available in the omni::behavior::tree::kw namespace (auto-imported inside BT_NODE_DESC):
valuePort — input port with a typed default:
Expression |
Result |
|---|---|
|
Type inferred as |
|
Type inferred as |
|
Untyped, default null, optional. |
|
Explicit accepted types |
|
Explicit types, default null, optional. |
blackboardRef — reference-style blackboard port (auto-deref). The
runtime treats this as “the value at the slot the port references”:
getInput returns the dereferenced value, setOutput writes to that
slot. Use this when the node consumes or produces a typed value through a
blackboard slot (e.g. SetBlackboard’s data port, CheckBlackboard’s
read port).
Expression |
Result |
|---|---|
|
Key defaults to port name |
|
Key is |
Pointer-style blackboard ports. When a node needs the slot identity
itself rather than the dereferenced value (e.g. PushQueue /
PopQueue invoke methods on the slot), declare a value port carrying
a BlackboardRef instead:
valuePort("queue", BlackboardRef{}).displayName("Queue")
The handler receives the raw BlackboardRef via ctx.getInput<BlackboardRef>
and resolves it to its target blackboard with ref.resolve(ctx.getTree()).
Blackboard scopes. A BlackboardRef carries (blackboard, key);
the blackboard field selects a scope:
empty: the tree’s externally-provided main blackboard (
tree->getBlackboard())."local": the tree’s per-instance hidden local blackboard, seeded from the descriptor atcreateTreetime.
Authors seed the local blackboard via entry-level methods on the
descriptor — setLocalEntry / getLocalEntry / getLocalKeys / eraseLocalEntry.
The seed lives as a plain dictionary on the descriptor (no
IBehaviorBlackboard instance, so it cannot be aliased into another
tree’s main blackboard). Entries serialize to / from the descriptor
JSON’s optional localBlackboard field. At createTree the factory
clones the seed into a per-instance hidden blackboard owned by the tree;
BlackboardRef("local", k) is the only way to reach it at runtime.
Note
In the editor UI this concept is surfaced as the Variables panel and the Variables submenu under Instance Override. Variables and local blackboard are interchangeable names for the same store.
outputPort — modifier output port:
Expression |
Result |
|---|---|
|
Typed output with default. |
|
Untyped output. |
Chaining methods on any port:
Method |
Description |
|---|---|
|
Display name in the editor (otherwise uses port name). |
|
Tooltip documentation. |
|
Restricts to string enum choices. Default becomes the first value. |
|
Marks the port as accepting array values. |
Pre-defined type sets:
Constant |
Types |
|---|---|
|
|
|
|
|
|
|
Individual vector types |
|
USD prim path type |
PortValue#
Wraps a default value and accepted types for port declarations:
Constructor |
Behavior |
|---|---|
|
Untyped, null default (optional port). |
|
Type inferred from value. Required port. |
|
Explicit types. Required if value is non-null, optional if |
BehaviorNodeLibraryBuilder#
Fluent builder for creating and registering a complete node library from C++.
#include <omni/behavior/tree/BehaviorNodeLibraryUtils.h>
static UniqueNodeLibraryPtr g_library;
void registerNodeLibrary()
{
g_library = BehaviorNodeLibraryBuilder("my_extension.nodes")
.setLibraryDoc("Nodes for my extension")
.registerNode<MyAction>()
.registerNode<MyComposite>()
.registerModifier<MyModifier>()
.validate()
.build();
}
Method |
Description |
|---|---|
|
Create builder for an unversioned library. |
|
Create builder for a versioned library (major.minor). |
|
Create builder with Kit extension id as version (e.g. |
|
Set the library documentation string. |
|
Register a node class with |
|
Register a modifier class with |
|
Check that all declared types have implementations. Errors are deferred to |
|
Finalize and return |