Language:
Page Info
Skill Level:
Engine Version:

Blueprint Variables

Choose your OS:

Variables are properties that hold a value or reference an Object or Actor in the world. These properties can be accessible internally to the Blueprint containing them, or they can be made accessible externally so that their values can be modified by designers working with instances of the Blueprint placed in a level.

Variables are displayed as rounded boxes that contain the name of the variable:

Variable Nodes

For information about using Matinee to modify the values of specific types of variables, see Modifying Blueprint Properties with Matinee .

Variable Types

Variables can be created in a variety of different types, including data types - such as Boolean, integer, and float - as well as reference types for holding things like Objects, Actors, and particular Classes. Arrays of each variable type can also be created. Each type is color coded for easy identification:

Variable Type

Color

Example

Usage

Boolean

Red

RedWire.png

Red variables represent Boolean (true/false) data.

Integer

Cyan

CyanWire.png

Cyan variables represent integer data, or numbers without decimals such as 0, 152, and -226.

Float

Green

GreenWire.png

Green variables represent float data, or numbers with decimals such as 0.0553, 101.2887, and -78.322.

String

Magenta

MagentaWire.png

Magenta variables represent string data, or a group of alphanumeric characters such as Hello World.

Text

Pink

PinkWire.png

Pink variables represent displayed text data, especially where that text is localization aware.

Vector

Gold

GoldWire.png

Gold variables represent vector data, or numbers consisting of float numbers for 3 elements or axes such as XYZ or RGB information.

Rotator

Purple

PurpleWire.png

Purple variables represent Rotator data, which is a group of numbers that define rotation in 3D space.

Transform

Orange

OrangeWire.png

Orange variables represent Transform data, which combines translation (3D position), rotation, and scale.

Object

Blue

BlueWire.png

Blue variables represent Objects, including Lights, Actors, StaticMeshes, Cameras, and SoundCues.

Variables in the My Blueprint Tab

The My Blueprint tab allows custom variables to be added to the Blueprint and lists any existing variables, including component instance variables added in the Components List or variables created by promoting a value to a variable in the graph.

My BLueprint Pane

Creating Variables

Creating a variable inside a Blueprint can be achieved by following the steps below.

  1. Create a Blueprint and open it up to the Graph tab.

  2. Create a new variable from the MyBlueprint window, by clicking on the Add Button plus_Button.png on the variable list header myblueprint_variable.png.

    MyBlueprintPane_createVar.png

  3. A new variable will be created, prompting you to enter a name for it.

    HT5.png

    Enter a name for your Blueprint, then proceed to the Details panel to adjust the properties of the variable.

  4. In the Details panel, there are several settings that can be used to define how your variable is used or accessed.

    HT6.png

    In order to set the Default Value for a variable, you must first Compile the Blueprint.

Option

Description

Variable Name

The name of the variable.

Variable Type

Set the Variable Type via the dropdown menu and determine if the variable is an Array or not.

Editable

Whether the variable is publically editable on instances of the Blueprint.

Tooltip

Extra information about this variable, shown when the cursor is over the variable.

Expose on Spawn

Should the variable be exposed as a pin when spawning the Blueprint.

Private

Should the variable be private (derived Blueprints cannot modify it).

Expose to Matinee

Should the variable be exposed for Matinee to modify it.

Config Variable

Allows the variable to be set from a config file.

Category

Allows you to categorize the variable by a label given. Variables will be sorted by their label.

Replication

Should this variable be Replicated over the network or not.

There are some serialization options that can be defined by expanding the Details panel as well.

HT37.png

Here you can set whether or not the variable is serialized and is zero-filled at load with the Transient option. You can also set whether or not the variable is serialized for saved games with the SaveGame option.

Editable Variables

When a variable is set to Editable, this allows the variable to be modified from outside of the Blueprint that the variable resides in.

HT21.png

You can set a variable to Editable from either the Details panel under the Editable setting, or by clicking the Closed Eye icon next to the variable inside the MyBlueprint window. When the eye icon is closed, the variable is currently set to non-editable (which is the default setting). When the eye icon is open, the variable is set to Public (or Editable as seen below).

When a variable is set to Editable, you can set the value of the variable from the Details panel of the Main Editor window.

HT23.png

Above, the variable LightColor has been set to Editable and we can now set this value in the Details panel of the Level Editor.

Variable Tooltips

You can also add a Tooltip for your variables that will appear when mousing over the variable in the editor.

HT25.png

You can add the Tooltip from the Details panel of the variable. When doing so, if the variable is set to Public, the Eye Icon will change from yellow to green indicating that a Tooltip has been written for the variable.

HT24.png

Expose on Spawn

The Expose on Spawn option allows you to set if the variable should be accessible at the time of spawning the Blueprint it sits in.

HT26.png

Above we have a variable called LightColor which is a Linear Color property that is set to Expose on Spawn. This variable is implemented in a Blueprint for a Point Light that uses the Set Light Color node and the LightColor variable to determine the color the light should be.

Below, inside a different Blueprint, a script is used to spawn the Point Light Blueprint and since the LightColor variable was set to Expose on Spawn, the option to set the value is made available on the Spawn Actor from Class node, allowing us to set its color when the light spawns in the game world.

HT27.png

Private Variables

With the Private option checked on a variable, this prevents the variable from being modified from external Blueprints.

For example, we have a variable below that is not set to private:

HT42.png

Inside another Blueprint, we spawn the Blueprint that contains the variable, then off the Return Value we can access our variable.

HT43.png

If we were to set it Private however:

HT41.png

And spawn the Blueprint again and try to access that variable, we cannot.

HT44.png

Expose to Matinee

In order for a variable to be affected by Matinee, you need to check the Expose to Matinee option.

HT31.png

Below, we have created a Matinee and added a track containing our Blueprint. We then want to modify the Linear Color variable in that Blueprint through Matinee and can do so by adding the LinearColor Property Track.

HT32.png

We are then prompted to select the LinearColor variable to modify from our Blueprint (our LightColor) property.

HT33.png

Once we have done so, we can then add keys to the track to modify the value of the variable over time.

HT34.png

See the Matinee and Cinematics documentation for more information on working with Matinee.

Promoting to Variable

You can also create variables by using the Promote to Variable option.

Right-click on any input or output data pins on a Blueprint node and select the Promote to Variable option.

HT38.png

By Right-clicking on the New Light Color pin and selecting Promote to Variable, we can assign a variable as the New Light Color value.

HT40.png

Alternatively, you can drag off an input or output pin and select the Promote to Variable option.

HT39.png

Accessing Variables in Blueprints

When working with variables in Blueprints, typically you will be accessing them in one of two ways: by use the Get node (referred to as a Getter) to get the value of the variable or using the Set node (referred to as a Setter) to set the value of the variable.

HT45.png

You can create a Set node (1 above) or Get node (2 above) for a variable by Right-clicking in the graph and typing either Set (variable name) or Get (variable name). Another method you can use is to hold down the Ctrl key and drag in the variable from the MyBlueprint window to create a Get node or hold down the Alt key and drag in the variable from MyBlueprint window to create a Set node.

Editing Variables

Variable values can be set either as a part of the Blueprint node network or as a default value prior to execution. To set variable default values:

  1. Click the Class Defaults button on the Blueprint Editor Tool bar to open the Defaults in the Details panel.

  2. In the Details panel, enter the desired default values to the right of your variable name.

    blueprint_details_variable_callout.png

    Above we have highlighted our Color variable in which we can set its default color.

If you do not see your variable listed in the defaults, make sure you have clicked the Compile button.

Renaming Variables

To rename a variable:

  1. Right-click on the variable name in the My Blueprint tab and select Rename in the menu that appears.

    rename_variable_menu.png

  2. Type the new variable name in the text box and then press Enter to save it.

    rename_variable.png

Variable Properties

You can set all the properties for a variable in the Details panel. Some variables may have more properties than those shown here, such as Expose to Matinee for Vectors or a Slider Range for numeric variables like Integers or Floats.

Property

Description

Variable Type

Set the variable type in the dropdown menu and determine whether or not the variable is an array.

Editable

Set whether or not it is possible to edit the value of the variable in the Class Defaults and the Blueprint's Details tab.

Tooltip

Set the tooltip for the variable.

Private

Set whether or not this variable should be private and not modified by derived Blueprints.

Category

Choose from an existing category or type a new Category name. Setting the Category determines where the variable appears in the Class Defaults, the My Blueprint tab, and the Blueprint's Details tab.

Replication

Choose if the variable's value should or should not be replicated across clients, and if the value is replicated, if there should be a notification by way of a callback function.

Getting & Setting Variable Values

Variables can also be edited as a part of your Blueprint network by way of Get and Set nodes. The easiest way to create these is by dragging a variable from the Variables tab directly into the Event Graph. A small menu will appear asking if you would like to create a Get or Set node.

VariableGetSet.png

Get Nodes

Get nodes supply portions of the network with a variable value. Once created, these nodes can be plugged into any node that takes the appropriate type.

GetVariable.png

Set Nodes

Set nodes allow you to change the value of a variable. Note that these must be called by an execution wire in order to execute.

SetVariable.png

Shortcuts when dragging from the My Blueprint tab

Ctrl-drag

Creates a Get node.

Alt-drag

Creates a Set node.