Arrays for Beginners | Unreal Engine Blueprints

What is an Array?

An array in Unreal Engine is essentially an ordered list of stored data.

Think of it as a list of variables, each variable is a box (array element) that holds a value, such as a number or a piece of data. These boxes are placed next to each other, one after the other, inside a bigger box, forming an array.

Now, to find a specific box in the array, you don’t refer to it by its color or shape. Instead, you use its position in the row.

The first element is at position 0, the second at position 1, and so on. This position is what we call an index.

So, an array is like a row of numbered boxes where you can store and retrieve values based on their position in the row (the array index). This helps organize information in a structured way, making it easier to work with sets of data.

However, like variables, an array can only store a single type of data.

For example, a String Array can only have String Values, and an Integer Array only integer values.

You can easily differentiate array types by their colors and by the symbol formed by 9 squares. Colors will also follow the array nodes like ‘add’ or ‘get’.

Array Example Unreal Engine

Creating an Array in Unreal Engine

Create a Variable

The first step to create an array is just to create a variable.

To do this, go to the Event Graph inside a Blueprint and press the + icon in the variables section.

Alternatively, right-click on the panel and select ‘Variable‘.

Create Variable in Unreal Engine

Next, give the variable a name and select the variable type.

Tip: If you prefer shortcuts, right-click on the variable type to directly change it to an array.

Don’t forget to Compile.

Compile Unreal Engine

Change a variable to an array in Unreal Engine

Now, select the variable you just created, and in the Details tab, change the Variable Type from ‘Single’ to ‘Array‘.

The icon should change to the 9 square grid.

Unreal Engine String Array

How to set default elements for an array

To add elements to the default array, go to the ‘Default Value’ section, and press the + button.

This will create a new index in the array list. Repeat this process for however many elements you want in the Array.

Keep in mind that the way you set the value depends on the type of Array you’re using.

If you need to insert, remove, or duplicate an Array index, click the arrow button next to the entry to bring up the edit menu.

Tip: Keep in mind that if you delete an array element, the index numbers will shift.

Do arrays allow duplicated or empty elements?

Yes. Arrays can have all the duplicate elements you want because each element has a unique index number.

It is also possible to have an empty array element. So, you are using an array index, but the value is blank. Just like having an empty box, but it is still part of the ordered array.

Tip: Arrays start counting at zero to simplify things for computers. When using arrays, remember that positions range from 0 to the array size. For instance, an array with 6 elements goes from index 0 to 5.

Array Debug Unreal Engine

Tip: If you select a debug object while playing, you can place the mouse cursor on the array symbol and then press the arrow down to see the elements that are currently in the array.

Basic Array Nodes in Unreal Engine

How to add elements to an array? (Add, Add Unique)

To add elements in Blueprints to an array, we will need one of the following nodes: ‘Add‘ or ‘Add Unique‘. Although they do more or less the same thing, they have a key difference.

The ‘Add‘ node will add elements to the array, but it will also allow duplicate elements.

On the other hand, ‘Add Unique‘ will add elements to the array, but it will first check if there are duplicates. If the element is duplicated, it won’t be added to the array.

Unreal Engine Add Unique Blueprints

This node is particularly useful when working with object references, especially if you don’t want duplicated references, for example, when dealing with a list of characters or weapons.

The integer output will return the index of the element we are adding to the array. You can check this using a Print String.

More Array Actions

There are plenty of actions you can perform with arrays in Unreal Engine after creating one.

You can find a list of all the actions in the ‘Utilities -> Array‘ section of Blueprints.

I will cover all the array nodes in the Blueprint List of this blog in the future, but there are a lot, so it may take a bit of time.

Meanwhile, there is a list of the most common nodes in the Unreal Engine Documentation.

Array Actions Unreal Engine

Unreal Engine Learning Path