Confusion about component creation, and crash

I’ve been searching like crazy and i come up with a solution for the problem i’m having.
But I’m confused on how to do this right.

I’m creating an actor that will have multiple static meshes.

UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = “Tile”, meta = (AllowPrivateAccess = “true”))
class UStaticMeshComponent* m_appropriateName;
I’ve got a bunch of theese ^

I create these in the constructor…And from what i’ve learned i use the CreateDefaultSubobject function.

But when i used that function on all of the 5 meshes, The editor would crash, telling me Default subobject already exists.

I changed everything except the first mesh im creating. Using the ConstructObject<>() function instead. Wich works.

So… when should i use what? What is the difference really?

I see that in the editor, there is no difference.

Have a great day! Appreciate your time.

You need to make sure each DefaultSubobject has a unique name:

MyFoo = CreateDefaultSubobject<UFoo>(TEXT("Foo0"));
MyOtherFoo = CreateDefaultSubobject<UFoo>(TEXT("Foo1"));

Ah thank you! that was it.
I guess i should take a break. Working without breaks results in silly mistakes like this :).