Unity3d 使用 Node Canvas

发表于2017-11-27
评论0 3.4k浏览

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.

如社区发表内容存在侵权行为,您可以点击这里查看侵权投诉指引