Blueprint Arrays

Arrays.png

Just as with variable values, Blueprints can store data within Arrays. If you are not versed in programming terms, you can think of an Array as a collection of variables all housed within a single unit.

An Array can only hold values of a single type. For instance, a Boolean Array can only hold Boolean values.

Array variables will contain a 3x3 colored grid to show that they are Arrays and not regular variables. In the case of a disconnected Array, that grid will have a darkened center. Once connected, the entire grid will be visible, as seen below.

GridIcon.png

Creating Arrays

Creating an Array is as simple as clicking on the Array grid icon when creating a variable.

example_variable_array.png

Once this icon is selected, the new item will be an Array rather than a standard variable.

array_selected.png

Editing Arrays

You can edit the value of an Array either via the Blueprint Default settings, or at any point along a Blueprint node network. These networks can be in the Construction Script, a function, a macro, or an Event Graph.

Array Defaults

Setting the default values for an Array is very easy. Simply create the necessary Array and enter the Class Defaults tab or the Defaults mode of the Blueprint Editor. You will see a section named for your Array, as shown below:

StringArrayDefaults.png

If you do not see your Array listed in the Class Defaults, make sure that you have compiled your Blueprint since the Array was created.

To edit the values of an Array's defaults:

  1. In the Class Defaults tab, click the button_plus.png button. This will create a new index. Repeat for as many items as you would like the Array to contain.

    StringArray_IndicesAdded.png
    In this example, 3 indices have been added.

  2. Set each value accordingly. Note that the way in which you set the value will depend on the type of Array in use.

    StringArrayDefaultsSet.png

  3. To insert, remove, or duplicate an Array index, click the button_ellipse.png button next to the entry to bring up the edit menu:

    StringArrayEdit.png

    If you add or remove indices from the middle of the list, the remaining numbers will automatically update.

Setting Array Values via Node Networks

If your Array is intended to be populated at runtime, you will generally not use defaults. Rather, you will use nodes within the Construction Script or an Event Graph to populate each index. For instance, you could use the Add or Insert nodes to add a new value to the next available index, or to insert a value at a given index, respectively.

AddArray.png

For a complete list of the Array control nodes within Blueprints, please see the Array Nodes page.

Array Indices

It is also important to note that values within an Array are given zero-based index values, meaning that the first index is 0, not 1. For example, if you were to add five items to an Array, the list would, internally, look something like this:

Index 0 First Item
Index 1 Second Item
Index 2 Third Item
Index 3 Fourth Item
Index 4 Fifth Item

This is important to keep in mind, as there will be times when you need to call on a specific item by its index value.