Unreal Engine 5 · Blueprint → C++
Array Insert & Clear in Unreal Engine 5 C++UE Docs
The Blueprint Insert node maps to TArray::Insert at a given index, and the Clear node maps to TArray::Empty, which removes all elements in Unreal Engine 5 C++.
Blueprint node & C++ equivalent
Numbers.Insert(99, /*Index=*/0);
Numbers.Empty();What do the Insert and Clear nodes do?
Insert places a new element at a specific index, shifting later elements to make room rather than overwriting them. Clear empties the array entirely. Both operate on a TArray.
The C++ equivalent
Numbers.Insert(99, 0) inserts the value 99 at index 0 and moves every existing element one slot to the right. Numbers.Empty() removes all elements and frees the array's allocated memory. After Empty, Num() returns 0.
Empty vs Reset
Empty clears the elements and releases the allocation by default, though you can pass a slack count to keep capacity. Reset clears the elements but keeps the existing allocation, which is faster when you plan to refill the array immediately. Choose Reset in hot loops to avoid repeated reallocations.
Frequently asked questions
How do you insert an element at an index in a TArray?+
Call MyArray.Insert(Value, Index). It places the value at that index and shifts the remaining elements toward the end.
How do you clear all elements from a TArray in UE5?+
Call MyArray.Empty() to remove every element. Use Reset() instead if you want to keep the allocated capacity for reuse.