Action Graph Quickstart

In this tutorial, you use OmniGraph in Omniverse Create to move a mesh in response to a key press.

Note

While you use Omniverse Create in this tutorial, you can follow similar steps to achieve the same results in other Omniverse Apps.

Before You Begin

While this is an introductory-level tutorial on OmniGraph, we recommend you complete Introduction to OmniGraph first. That tutorial provides more detailed information about some of the same steps that you complete here.

Load the OmniGraph Extensions

First, load the Action Graph Bundle extension into Create:

Numbered steps for adding the Action Graph extension.

Prepare Your Scene

Next, prepare your empty scene by adding a torus:

Numbered steps for creating a torus.

Create a New Action Graph

Create a new Action Graph so you can trigger action in response to a particular event:

Numbered steps for creating a new Action Graph.

Use an On Keyboard Input Node

Search for the On Keyboard Input node, drag it into the editor, and set its Key In to J:

Numbered steps for using an On Keyboard Input node.

On Keyboard Input is an event-source node. When the user presses the J key, the outputs:pressed attribute is enabled. You use this attribute to trigger an action later in this tutorial.

Use a Write Prim Attribute Node

Drag the torus prim from the Stage to the Action Graph editor, and select Write Attribute:

Numbered steps for using a Write Prim Attribute node.

Then, set its Attribute Name to xformOp:translate:

Numbered steps for setting the Write node's attribute.

This means you want to translate, or move, the torus.

Use a Constant Point3d Node

Search for the Constant Point3d node, drag it into the editor:

Numbered steps for using an On Keyboard Input node.

Notice that the X, Y, and Z input values are all set to 0.0 in the Property panel. This points your constant point at the origin of the scene.

Wire up the Nodes

Now, it’s time to wire up your nodes and direct the flow of execution.

Move the Torus to the Origin

Click and drag the Constant Point3d node’s Value pin to the Write Prim Attribute node’s Value pin:

Connect the constant and write prim attribute nodes.

This takes the constant value, a 3-tuple representing the origin of the scene, and writes it to the torus’s xformOp:translate attribute. In other words, it moves the torus to the origin.

Move the Torus on Key Press

Next, click and drag the On Keyboard Input node’s Pressed pin to the Write Prim Attribute node’s Exec In pin:

Connect the keyboard input and write prim attribute nodes.

This moves the torus to the origin when the user presses the J key.

Technical Detail

The execution evaluator works by following node connections downstream and computing the nodes that it encounters until there are no more connections to follow.

In this case, the evaluator executes the network downstream from outputs:pressed attribute, whose next node is the Write Prim Attribute node. Before that can be computed, though, the evaluator evaluates its upstream data-dependency: the Constant Point3d node. Finally, the Write Prim Attribute node is computed, which sets Torus.xformOp:translate to (0, 0, 0), the origin.

Review Your Work

Click Play in your scene’s toolbar, move the torus away from the origin, and press J:

The torus snapping back to the origin.

The torus snaps back to the origin.

Alternate Actions with a Flip Flop Node

Next, make this network a little more interesting by cycling the location of the Torus on key press.

Use a Flip Flop Node

Search for the Flip Flop node, drag it into the editor:

Numbered steps for using a Flip Flop node.

The Flip Flop node alternates activating one of two downstream networks every time it’s computed. You use this to cycle through two behaviors.

Right-click and disconnect the existing node connections to prepare to use your Flip Flop node.

Duplicate Your Constant and Write Prim Nodes

Use Ctrl-D to duplicate your Constant Point3d and Write Prim Attribute nodes:

Numbered steps for duplicating the constant and write prim nodes.

Rearrange the nodes so that you can easily see them.

Tip

You can marquee-select or Ctrl-select both nodes to duplicate them simultaneously.

Change the Inputs Values for the New Constant Point3d Node

Set the Y input value to 250.0 for your new Constant Point3d node:

Change the new constant node's input values.

This stores the coordinates for a point that is 250 units away from the origin on the positive Y axis.

Wire up the Flip Flop Node

Wire up the Flip Flop node to evaluate one Write Prim Attribute node for Execute A and the other node for Execute B:

Wire up the Flip Flop node.

Test Your Flip Flop Node

Click Play in your scene’s toolbar. Every time you press J, the torus will alternate between the origin and 250 units in the positive direction on the y-axis:

Cycling the torus's position.

Common Problems and Caveats

If you run into problems or have questions, read through this section to, hopefully, find an explanation:

Common Problem/Question

Explanation

You can’t connect to a node input due to incompatible types.

Remove all connections from the target node and reconnect. When extended types are resolved, the node has to be disconnected to reset the types.

The Property window shows “token” as the type of attributes instead of the actual type. And what are all these “__resolved” attributes?

Nodes with extended attributes show attributes like “__resolved_outputs:tuple”. This is a faithful display of the underlying implementation in the file.

It’s set up correctly, but isn’t working.

Check the Console panel for error or warning messages, try saving and reloading the scene, and ensure you’ve loaded the Action Graph extensions bundle.

What about subgraphs with different evaluation? (push, pull, dirty_push)

An Action subgraph in an Action Graph organizes nodes but has no further semantics. You can add a Push subgraph to an Action Graph, and vice versa. The system ticks each graph, but connections between them are not supported at this point. Instead, you can use shared data to communicate between the two graphs (For example, a prim attribute).