{ }Blueprint → C++

Unreal Engine 5 · Blueprint → C++

Add / Remove Array Element in Unreal Engine 5 C++UE Docs

The Blueprint Add and Remove array nodes correspond to TArray::Add, TArray::Remove (removes by value), and TArray::RemoveAt (removes by index) in Unreal Engine 5 C++.

Blueprint node & C++ equivalent

C++
TArray<int32> Numbers;
Numbers.Add(5);
Numbers.Remove(5);        // remove by value
Numbers.RemoveAt(0);      // remove by index

What do the Add and Remove array nodes do?

In Blueprint, Add appends a new element to the end of an array, while Remove deletes matching elements. The Remove Index node deletes whatever element sits at a given position. These map to a TArray, the standard dynamic array container in Unreal Engine 5.

The C++ equivalent

Declare a TArray<int32> and call Add to append. Numbers.Add(5) pushes the value 5 to the end and returns its index. Numbers.Remove(5) removes every element equal to 5 and returns the count removed. Numbers.RemoveAt(0) removes the element at index 0 and shifts the rest down.

When to use Remove vs RemoveAt

Use Remove when you know the value but not the position; it performs a linear search and removes all matches. Use RemoveAt when you already have the index, since it skips the search. For removing without preserving order, RemoveAtSwap is faster because it moves the last element into the gap instead of shifting.

Frequently asked questions

How do you add an element to a TArray in UE5 C++?+

Call MyArray.Add(Value). It appends the value to the end of the array and returns the index it was placed at.

What is the difference between Remove and RemoveAt in TArray?+

Remove deletes elements that match a value, while RemoveAt deletes the element at a specific index. RemoveAt does not need to search the array.

Related Arrays & Containers nodes

View all Arrays & Containers nodes →