Menu
Lumberyard
User Guide (Version 1.15)

Managing Script Canvas Variables

The Variable Manager shows the variables that are used in your Script Canvas graph. These variables represent the custom data required to build game logic. For example, you can use variables to make counters, store entity references, specify a direction, or define a color.

Adding and Configuring Variables

You can add variables to your Script Canvas graph to declare and initialize them.

To add and configure a variable

  1. In the Script Canvas editor, open your Script Canvas graph or create one.

  2. In the Variable Manager, click Create Variable and then choose your variable type. You can search to filter the list of variable types.

    Note

    Common variable types are pinned to the top of the list by default. You can customize the pinned list to show the variable types that you use most often. To do so, click the box to the left of a variable type to pin or unpin it.

    
                        Choose from variable types in the Script Canvas Variable
                            Manager.
  3. In the Node Inspector, configure the properties for your variable.

    
                        Configure variable properties in the Script Canvas Node
                            Inspector.

    For example, if you add a Color variable, you can do the following:

    • For Name, enter a name to identify that color variable. You can also double-click the name in the Variable Manager to rename the variable.

    • For Color, enter an RGB value or use the color picker.

    • Select Expose on Component to show the variable property and value under the assigned Script Canvas component in the Entity Inspector.

      Note

      This setting allows you to use the same Script Canvas graph for more than one entity, but customize part of the graph for a specific entity. When you change the variable value on a component, that value takes precedence over the default value that is specified in the graph.

      
                                Example of Color variable properties in the Script Canvas
                                    Node Inspector.
  4. In the Script Canvas editor, choose File, Save to save your changes.

Setting Default Values for Variables

You can set the default value for variables in the Node Inspector or the Variable Manager.

To set variable values

  1. In the Variable Manager, select the variable that you want to update. You can search to filter the list of variables that are in your graph.

  2. Do one of the following to update the properties for your variable:

    • In the Node Inspector, update the variable values as needed.

      
                                Set the variable default values in the Node
                                    Inspector.
    • In the Variable Manager, update certain variable values. These values appear in a third column and can be selected or double-clicked.

      
                                Set the variable default values in the Variable
                                    Manager.
  3. In the Script Canvas editor, choose File, Save to save your changes to the graph.

Creating Get or Set Variable Nodes

You can use get and set variable nodes to retrieve or set the variable's value.

To create get or set variable nodes

  • Do one of the following:

    • Drag the variable from the Variable Manager to the canvas, and then choose Get variable name or Set variable name.

    • Right-click the variable in the Variable Manager and choose Get variable name or Set variable name.

      
                                Right-click to create a get or set variable in the
                                    Script Canvas Variable Manager.
    • Use the following keyboard shortcuts:

      • Press Shift and drag the variable from the Variable Manager to the canvas to create a get variable node.

      • Press Alt and drag the variable from the Variable Manager to the canvas to create a set variable node.

Deleting Variables

You can delete variables from the graph or the Variable Manager.

To delete a variable

  • Do one of the following:

    • Select the variable node in the canvas and press Delete.

    • Select the variable in the Variable Manager and press Delete.

    • Right-click the variable in the Variable Manager and choose Delete variable name.

      
                                Delete a variable in the Script Canvas Variable
                                    Manager.