I’ve followed a tutorial to create a simple AI, and it implements a TArray, something that i had not seen before. Upon reading the docs, i saw that it would be similar to making an array of the same type as the TArray<>.
So the question is, would there be any significant difference between the following declarations?
TArray is a dynamic array, meaning it’s size can change at runtime. It owns it’s own memory and can allocate it on demand, and also provides runtime bounds-checking etc.
[] is a fixed-size array, it’s size cannot change at runtime and its memory is owned by whatever class/struct etc, it belongs to. There are no runtime safety checks etc since it’s a native part of the language - but you can treat it like a TArray by using TArrayView with it (not required).
You can use both with reflection/UPROPERTY. Whether you should use one or the other is really more of a design decision, but most of the engine deals with TArray and it’s often much more useful for gameplay code etc.
TArray is comparable to std::vector - so most of the general subject matter on std::vector will also apply to TArray.