Array Nodes

An array is a list of variables of the same data type. You can have an array of Integers, an array of Strings, and so on. To create an array, first create a regular variable with the data type you want the array to use, and then click on the grid icon to the right of the Variable Type property in the Details Panel. There are several Nodes custom-made to work with arrays in the Utilities > Array category of the Node Menu.

Add Node
Add Unique Node
Append Array Node
Clear Node
Contains Item Node
Filter Array Node
Find Item Node
ForEachLoop Node
ForEachLoopWithBreak Node
Get Node
Insert Node
Is Valid Index Node
Last Index Node
Length Node
Make Array Node
Remove Index Node
Remove Item Node
Resize Node
ReverseForEachLoop Node
Set Array Element Node
Shuffle Node

Add Node

Add Node
Add Node

The Add Node can be used to add another element to the end of an array. It has an input pin for the array itself and an input pin for the variable containing the value to add. It will return an integer containing the index where the new element was added.

Add Unique Node

Add Unique Node
Add Unique Node

The Add Unique Node will add another element to the end of an array if the array doesn’t already contain an element of the same value. It has an input pin for the array itself and an input pin for the variable containing the value to add. It will return an integer containing the index where the new element was added, or the enum INDEX_NONE if the array already contained the element.

Append Array Node

Append Array Node
Append Array Node

The Append Array Node will append the array connected to its second array input pin to the end of the array connected to its first array input pin.

Clear Node

Clear Node
Clear Node

When you want to remove elements from an array, there are a few ways to do this. The Clear Node simply deletes all the elements of an array.

Contains Item Node

Contains Item Node
Contains Item Node

When you just want to know whether or not an array contains a certain value, you can use the Contains Item Node. You specify the value you want to search for and it will output True if that value was found and False if it was not.

Filter Array Node

Filter Array Node
Filter Array Node

The Filter Array Node extracts only the elements of an array that belong to a particular sub-class. For example, if you passed an array of Pawns into the Target Array and then specified the Character class in the Filter Class pin, the Filtered Array pin would output an array containing only those Pawns that are also Characters.

Find Item Node

Find Item Node
Find Item Node

If you need to know the index that a certain value is located at, you can use the Find Item Node. This will return the index of the first element of the array that matches the value specified. If no match is found, this will return a value of -1.

ForEachLoop Node

ForEachLoop Node
ForEachLoop Node

The ForEachLoop Node iterates through the elements of an array. It has an input pin called Array where you can input the array you wish to use. It has an output execution pin called Loop Body that activates once for each element in the array. So each time the Loop Body pin fires, the Node’s Array Element pin will contain the value of the current element, and the Array Index pin will contain the index number of the current element. The output execution pin Completed will fire once all the elements iterate through.

ForEachLoopWithBreak Node

ForEachLoopWithBreak Node
ForEachLoopWithBreak Node

The ForEachLoopWithBreak Node iterates through the elements of an array. It is identical to the ForEachLoop Node except that it has a second execution input pin called Break which will terminate the loop if activated. The Node has an input pin called Array where you can input the array you wish to use. It has an output execution pin called Loop Body that activates once for each element in the array. So each time the Loop Body pin fires, the Node’s Array Element pin will contain the value of the current element, and the Array Index pin will contain the index number of the current element. The output execution pin Completed will fire once all the elements iterate through.

Get Node

Get Node
Get Node

The Get Node of the Array category takes in an array and an index number as input and outputs the element contained at that index.

Insert Node

Insert Node
Insert Node

The Add Node will add a new element to the end of the array, but to add a new element somewhere in the middle you need to use the Insert Node. It has a pin to specify the array, a pin to specify the value you want to add, and a pin to specify at which index to insert the value.

When a value is inserted, the length of the array increases by one, all the values at the specified index and above get moved one index higher, and then the new value is assigned to the specified index. So the Insert Node inserts values in-between other values without erasing any data.

Is Valid Index Node

Is Valid Index Node
Is Valid Index Node

The Is Valid Index Node returns True if the array passed in contains the index number passed in, or returns False otherwise.

Last Index Node

"<yoastmark

The Last Index Node returns an array’s highest index number. Because arrays in Unreal Engine are zero-based, the last index of an array will always be one less than its length.

Length Node

Length Node
Length Node

The Length Node returns the number of elements an array contains.

Make Array Node

Make Array Node
Make Array Node

The Make Array Node defines a new array. You pass in the elements of the array into the input pins. You can add new pins using the “Add pin” button. The resulting array outputs from the Array pin.

Remove Index Node

Remove Index Node
Remove Index Node

The Remove Index Node will delete the element at the specified index, and then shift any values at higher indexes down one.

Remove Item Node

Remove Item Node
Remove Item Node

The Remove Item Node deletes elements based on their values, deleting any element whose value matches the one specified. The Remove Item Node also has a Boolean pin that outputs True if it finds a match.

Resize Node

Resize Node
Resize Node

The Resize Node will resize the array passed in to the number of elements passed in. If the new size passed in is smaller than the current size of the array, then elements drop from the end of the array. If the new size is greater than the current size, empty elements will be added to the end of the array.

ReverseForEachLoop Node

ReverseForEachLoop Node
ReverseForEachLoop Node

The ReverseForEachLoop Node iterates through the elements of an array in reverse order. It has an input pin called Array where you can input the array you wish to use. The Node has an output execution pin called Loop Body that activates once for each element in the array. So each time the Loop Body pin fires, the Node’s Array Element pin will contain the value of the current element, and the Array Index pin will contain the index number of the current element. The output execution pin Completed will fire once all the elements iterate through.

Set Array Element Node

Set Array Element Node
Set Array Element Node

If you want to replace the value of a certain index, you need to use the Set Array Element Node. Unlike the Insert Node, this Node will overwrite the value at the specified index and won’t change the location of any of the other values.

The Set Array Element Node has a Size to Fit pin. As an example, let’s say that at the time the Node fires, the array has 4 elements (indices 0 to 3). Also, let’s say you specify that you want the new value to go into index 6. If Size to Fit is False, this won’t work, because index 6 doesn’t exist. The game won’t crash, the array simply won’t change in any way. But if Size to Fit were True in this scenario, the length of the array would increase to 7, so that there is an index 6. Index 6 is set to the new value specified, and indices 4 and 5 simply remain empty.

Shuffle Node

Shuffle Node
Shuffle Node

The Shuffle Node will randomize the location of each of the elements within the array. For example, the element at index 0 might move to index 1 and the element at index 1 might move to index 0.