Action Graph Quickstart¶
The following are step by step instructions to set up an Action Graph which moves a shape in response to a keyboard press event.
Ensure that the following extension bundle is loaded:
Drop down a Torus by clicking on Create -> Mesh -> Torus, it will be named “Torus”, at path
Open up the graph editor UI by clicking on Window -> Visual Scripting -> Action Graph
In the new window, click on New Action Graph to create an empty action graph at the default path
Drop down an On Keyboard Input node. This can be done using the search box on the left.
Drag and drop
Torusfrom the Stage window onto the Action Graph editor, a dialog will appear with three choices. Choose Write Attribute, this will create a Write Prim Attribute node to read an attribute from the
Drop down a Constant Double3 node.
Expand all the nodes to the 3rd level of detail. This can be done using the button on the editor toolbar.
Wire constant_double3.outputs:value -> TorusWriteAttrib.inputs:value
Wire on_keyboard_input.outputs:pressed -> TorusWriteAttrib.inputs:execIn
Select on_keyboard_input and set Key In to
Jusing the Property window
Select TorusWriteAttrib, toggle on the Use Path checkbox, and set Prim Path to
Select TorusWriteAttrib and set Attribute Name to
Finally, click on the Play button on the far left side.
Move the torus away from the origin using the viewport.
Now press the
J key. Notice that the torus will snap back to the origin.
Congratulations! You have executed your first Action network. Lets look at how it works.
Action Graph Evaluation¶
The execution evaluator works by following execution connections downstream and computing nodes it encounters until there are no more downstream connections to follow.
on_keyboard_input is an event-source node. It will be listening for the indicated key
Jpressed event. When the key is pressed the outputs:pressed attribute will be enabled.
The next time the network is evaluated it will execute the network downstream from outputs:pressed attribute, which is TorusWriteAttrib.
Before TorusWriteAttrib can be computed, the evaluator will evaluate its upstream data-dependencies, which is constant_double3.
Finally TorusWriteAttrib is computed, which sets Torus.xformOp:translate to (0, 0, 0)
Flip Flop Flow Control¶
Let’s make this network a little more interesting by having the key event cycle the location of the Torus. Flip Flop is a node which alternates activating one of 2 downstream networks each time it is computed. We can use this to provide the cycling behavior.
TorusWriteAttrib. You can do this by marquee-selecting those 2 nodes, and pressing
Ctrl-D. Note that the duplicated nodes may be stacked on top of the old nodes, so you will have to move the nodes off of the stack.
Drop down a Flip Flop node
Select constant_double3_01 and set inputs:y to
250.0using the Property window
Wire up the nodes like so. Note that you can cut any extra connections by right clicking on the connected port.
Now when you press
J the torus will jump between (0, 0, 0) and (0, 250.0, 0) (assuming the play button is still in effect)
The editor won’t let you connect to a node input due to incompatible types
Try totally disconnecting the target node and re-connecting. When extended types are resolved the node has to be disconnected in order to reset the types.
It’s set up correctly but isn’t working
Check the Console panel for error or warning messages
Try saving and reloading the scene
Ensure that the extensions listed in step 1 are loaded.