#include "Containers/Array.h" // Declare an empty TArray of integers TArrayMyArray; // set the number of elements to 10 MyArray.SetNum(10);
#include "Containers/Array.h" // Declare an empty TArray of floats TArrayIn this example, we declare a new empty TArray of floats called OtherArray. We then use the SetNum function twice - first setting the number of elements to 5 and initializing all elements to 0.0f, and then setting the number of elements to 8 and initializing all elements to 1.0f. Package library: Unreal Engine C++ library.OtherArray; // set the number of elements to 5 and initialize all elements to 0.0f OtherArray.SetNum(5, false); // set the number of elements to 8 and initialize all elements to 1.0f OtherArray.SetNum(8, true, 1.0f);