Creating a StaticMesh and collision component correctly

Hello everyone. After testing and successfully creating a simple Actor with a StaticMesh and collision component, I have some unanswered questions.

I created the StaticMesh and collision component in three different manners in the constructor:

	StaticMesh = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("Static mesh"));
	StaticMesh->SetupAttachment(RootComponent);

	CollisionBox = CreateDefaultSubobject<UBoxComponent>(TEXT("Collision Box"));
	CollisionBox->SetupAttachment(StaticMesh);

This is my final code as it has no issues and I can edit the CollisionBox without deforming the StaticMesh.

	CollisionBox = CreateDefaultSubobject<UBoxComponent>(TEXT("Collision Box"));
	CollisionBox->SetupAttachment(RootComponent);

	StaticMesh = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("Static mesh"));
	StaticMesh->SetupAttachment(CollisionBox);

With this configuration, when I edit the transform of the CollisionBox (make it bigger to engulf all the mesh), it will also deform the StaticMesh as it is his children, so I disregarded it. A workaround could be to make the CollisionBox as big as you want and then edit the StaticMesh transform to fit it inside and to have a decent in-world size.

	CollisionBox = CreateDefaultSubobject<UBoxComponent>(TEXT("Collision Box"));
	CollisionBox->SetupAttachment(RootComponent);

	StaticMesh = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("Static mesh"));
	StaticMesh->SetupAttachment(RootComponent);

This I though it would work but I could not visualise my StaticMesh in the world. I could set it and see it in the editor, as well in the little preview of the content browser, but when
dragged into my world, it would be invisible.


Given this, I have two unanswered questions.

Regarding option 3, why does it not display the StaticMesh in the world?

Regarding option 2, I noticed it’s the same configuration as in the Character C++ class, so I find it odd. I checked my character and be default the size fits correctly, so this was not an issue, but I wonder if you use a bigger or wider mesh (any random creature), then chances are you will have to edit the default CapsuleComponent which as seen will too deform the mesh. Am I missing something here?

Thanks for your time reading this and hopefully it provides answers for people that noticed the same behaviour in the future :slight_smile: