Lets say I have the following code inside my class header:
UPROPERTY(EditAnywhere)
TArray<UBillboardComponent*> billboards;
and inside my constructor I have the following lines of code
for (int i = 0; i < MaxSystems + 1; i++)
{
billboards.Append( CreateDefaultSubobject<UBillboardComponent>(FName("System")) );
billboards[i]->SetRelativeLocation(FMath::VRand() * 500.0f);
}
Currently, this gives me an error stating:
Severity Code Description Project File Line Suppression State
Error (active) no instance of overloaded function "TArray<InElementType, InAllocator>::Append [with InElementType=UBillboardComponent *, InAllocator=FDefaultAllocator]" matches the argument list Game Projects\Unreal Engine 4\Project\Source\Project\Class.cpp 22
I believe that the compiler is telling me that UBillboardComponent is not supported by the default allocator and requires us to put in a new allocator, but I may be wrong.
I guess the short of my question is – how do I hold onto a TArray of components that are children to my root component? I would like to use an array specifically for the ability to access it using an index value (so billboards[i] will give me the appropriate billboard) so that my data and visuals can be kept in sync.