Unity3d 使用 Node Canvas,unity3dcanvas
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.
著作權聲明:本文為博主原創文章,未經博主允許不得轉載。