Hej,
In the below code, I’m trying to get the components of UStaticMesh Array, but i’m getting an error as follows.
Error 1 error C2338: ‘T’ template parameter to GetComponents must be derived from ActorComponent
In .h file
UPROPERTY()
TArray<UStaticMeshComponent*> StaticMeshComponent;
UPROPERTY()
TArray<UStaticMesh*> StaticMesh;
In .CPP file
StaticMeshComponent = TArray<UStaticMeshComponent*>();
StaticMeshtemp = TArray<UStaticMesh*>();
for (int32 i = 0; i < 3; i++)
{
GetComponents<UStaticMeshComponent>(StaticMeshComponent);
StaticMeshComponent[i] = CreateDefaultSubobject<UStaticMeshComponent>(temp);
GetComponents<UStaticMesh>(StaticMesh);
StaticMesh[i] = Cast<UStaticMesh>(StaticLoadObject(UStaticMesh::StaticClass(), NULL, *SMPath));
Is there any another function or method to get the components of UStaticMesh Array ???