Hej,
In the Below code, I've assigned StaticMeshComponent name as "StaticMeshComponentCOMP1, StaticMeshComponentCOMP2". It is not very efficient for N component.
for (int32 i = 0; i < 6; i++)
{
StaticMeshComponent[i] = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("StaticMeshComponentCOMP1"));
StaticMeshComponent[i] = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("StaticMeshComponentCOMP2"));
// more code here
}
So I've tried to assign StaticMeshComponent name as StaticMeshComponentCOMP with 'i' as below, but couldn't able to achieve the result.
for (int32 i = 0; i < 6; i++)
{
StaticMeshComponent[i] = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("StaticMeshComponentCOMP" + '%i'));
}
thank you for your help in advance
You have to create your name as a separate FString variable. FString then has several append-functions, e.g. AppendInt().
FString name = FString(TEXT("StaticMeshComponentCOMP"));
name.AppendChar('-');
name.AppendInt(i);