Node Canvas
Node Canvas是一个行为树的插件,它是图形化的操作模式,可以简化开发逻辑,官方文档在这 .
基本元素
流程上的原则是,一旦返回值为False
则向上返回。一般在BehaviourTreeOwner
组件上,要勾选Repeat
循环监测。通常这些监测指的是各子树的条件判断。常用的元素如下:
元素名称 |
对应逻辑 |
备注 |
Action |
操作 |
各种操作,用过都说好 |
Condition |
条件判断 |
各种判断,没它真不成 |
Selector |
选择器 |
逻辑|| 如果有返回为真的子树,则停止执行,返回真 |
Sequencer |
顺序器 |
逻辑&& 与Selector相反,有返回假的,则返回假 |
Parallel |
并行器 |
“同时”执行子树,返回值根据Policy取舍 |
Conditional |
条件节点 |
如果不合条件,直接返回False,不执行子节点 |
Filter |
过滤器 |
限制性访问,比如初始化时只进一次 |
Iterate |
迭代器 |
做循环用 |
OverrideAgent |
复写变量 |
对于子节点,不使用行为树挂载的Agent |
快捷键
Here are the node/canvas controls and shortcuts:
- Right Click on the canvas to add a new node.
- Click & Drag to pan the node.
- Middle Click & Drag in the canvas to pan the canvas.
- Shift + Click & Drag a node to pan it and all of it’s children together; panning a branch.
- Click & Drag from a port over a target node to connect. Right click a connected port to disconnect.
- Click & Drag from a port into empty canvas space, will show context menu to automaticaly create and connect a new node.
- Click a connected port or connection itself to select the connection.
- Delete the selected node or connection with Delete Key, or through the right click context menu.
- Duplicate a node with Control+D or through the right click context menu.
- Double Clicking a node will open it’s script in the IDE, unless it’s a Nested Node in which case it will open the nested tree.
- Relink a connection by click and dragging it over a new node.
- Hit “F” will focus the canvas on the center of all your nodes within it.
- Mouse Scroll Wheel will Zoom In/Out the canvas.
- Left Click and Drag in the canvas, will allow you to create a selection rectangle.
- Holding Control while making a rectangle selection will create a Canvas Group.
On right click on a node or connection, a context menu will show up. Depending on the node or connection type there might be different extra options. Following are the common operations:
- Delete: Deletes the Node or Connection. (available in multiselection as well).
- Copy Node: Copies the Node possible to Paste later. (available in multiselection as well)
- Copy Assigned Task: Will copy the task that has been assigned to the Node or Connection.
- Paste Assigned Task: Will paste the currently copied Task to the Node or Connection and assign it.